制作中文(繁简)的PDF

80酷酷网    80kuku.com

  中文有人还为无法用php_pdf做中文的pdf烦恼吧..
PHP_PDF套件在这边抓取,记得重新编译哦。用现成的会有MARK。
http://www.pdflib.com/pdflib/index.html

这是php_pdf配合Iconv转UTF-16做的简易制作中文PDF的范例。
此部份不包含排版。有空弟在写另外一个排版范例。

 
<?
$pdf pdf_new
();

pdf_open_file($pdf"./test.pdf"
);
pdf_set_info($pdf"Creator"iconv("BIG5","UTF-16","小企鹅"
));

pdf_begin_page($pdf595842
);
## BOOKMARK要用UTF-16的UNICODE哦
$Parent=pdf_add_bookmark($pdfIconv("BIG5","UTF-16","繁体中文"
));
pdf_add_bookmark($pdfIconv("BIG5","UTF-16","字体一"),$Parent
);
$font PDF_findfont($pdf"MHei-Medium""ETen-B5-H"0
);
PDF_setfont($pdf$font14
);
pdf_show_xy($pdf"海南搏浪岛浪搏南海"50750
);
pdf_end_page($pdf
);


pdf_begin_page($pdf595842
);
pdf_add_bookmark($pdfIconv("BIG5","UTF-16","字体一"),$Parent
);
$font PDF_findfont($pdf"MSung-Light""ETen-B5-H"0
);
PDF_setfont($pdf$font14
);
pdf_show_xy($pdf"白沙明月夜月明沙白"50750
);
pdf_end_page($pdf
);

pdf_begin_page($pdf595842
);
$Parent=pdf_add_bookmark($pdfIconv("BIG5","UTF-16","简体中文"
));
pdf_add_bookmark($pdfIconv("BIG5","UTF-16","字体一"),$Parent
);
$font PDF_findfont($pdf"STSong-Light""GBK-EUC-H"0
);
PDF_setfont($pdf$font14
);
pdf_show_xy($pdf"奻漆赻懂厄厄懂赻漆奻"50750
);
pdf_show_xy($pdf"笢刓甜菱豪豪菱甜刓笢"50650
);
pdf_end_page($pdf
);

/*
    中文 encoding 的部分
    { "GB-EUC-H",       cc_simplified_chinese },
    { "GB-EUC-V",       cc_simplified_chinese },
    { "GBpc-EUC-H",     cc_simplified_chinese },
    { "GBpc-EUC-V",     cc_simplified_chinese },
    { "GBK-EUC-H",      cc_simplified_chinese },
    { "GBK-EUC-V",      cc_simplified_chinese },
    { "UniGB-UCS2-H",   cc_simplified_chinese },
    { "UniGB-UCS2-V",   cc_simplified_chinese },

    { "B5pc-H",         cc_traditional_chinese },
    { "B5pc-V",         cc_traditional_chinese },
    { "ETen-B5-H",      cc_traditional_chinese },
    { "ETen-B5-V",      cc_traditional_chinese },
    { "ETenms-B5-H",    cc_traditional_chinese },
    { "ETenms-B5-V",    cc_traditional_chinese },
    { "CNS-EUC-H",      cc_traditional_chinese },
    { "CNS-EUC-V",      cc_traditional_chinese },
    { "UniCNS-UCS2-H",  cc_traditional_chinese },
    { "UniCNS-UCS2-V",  cc_traditional_chinese },
    汉字型的部分

    "MHei-Medium",
    "MSung-Light",
    "STSong-Light",

*/

pdf_close($pdf
);
pdf_delete($pdf
);
?>


分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: