PHP Development example: create the program code of the PDF Chinese document

Source: Internet
Author: User
I used FPDF (www.fpdf.org). after downloading the fpdf class library, I also used the following Chinese library to support Chinese characters, but only one Chinese font (文) can be used ). For this reason, I have been worried for a long time, and now I have finished it.

I used FPDF (www.fpdf.org). after downloading the fpdf class library, I also used the following Chinese library to support Chinese characters, but only one Chinese font (文) can be used ). For this reason, I have been worried for a long time, and now I have finally finished it. I will convert the TrueType font to the pt1 font application:

The following is a Chinese library found on FPDF:

Require ('fpdf. php ');
$ Big5_widths = array (''=> 250 ,'! '=> 250, ''' => 408,' # '=> 668,' $ '=> 490,' % '=> 875,' & '=> 698, ''' => 250,
'(' => 240, ')' => 240, '*' => 417, ''=> 667, ',' => 250, '-' => 313 ,'. '=> 250,'/'=> 520, '0' => 500, '1' => 500,
'2' => 500, '3' => 500, '4' => 500, '5' => 500, '6' => 500, '7' => 500, '8' => 500, '9' => 500, ':' => 250, ';' => 250,
'<' => 667, '=> 667,'> '=> 667 ,'? '=> 396,' @ '=> 921, 'a' => 677,' B '=> 615, 'C' => 719, 'D' => 760, & apos; E & apos; = & apos; 625 & apos,
'F' => 552, 'G' => 771, 'H' => 802, 'I' => 354, 'J' => 354, 'K' => 781, 'L' => 604, 'M' => 927, 'n' => 750, 'O' => 823,
'P' => 563, 'q' => 823, 'R' => 729, 's' => 542, 'T' => 698, 'U' => 771, 'V' => 729, 'W' => 948, 'x' => 771, 'y' => 677,
'Z' => 635, '[' => 344, ''=> 520, ']' => 344, '^' => 469, '_' => 500, ''' => 250, 'A '=> 469,' B '=> 521, 'C' => 427,
'D' => 521, 'E' => 438, 'F' => 271, 'G' => 469, 'H' => 531, 'I => 250, 'J' => 250, 'K' => 458, 'L' => 240, 'M' => 802,
'N' => 531, 'O' => 500, 'P' => 521, 'q' => 521, 'R' => 365,'s '=> 333, 'T' => 292, 'u' => 521, 'V' => 458, 'W' => 677,
'X' => 479, 'y' => 458, 'Z' => 427, '{' => 480, '|' => 496, '}' => 480 ,'~ '=> 667 );
$ GB_widths = array (''=> 207 ,'! '=> 270, ''' => 342,' # '=> 467,' $ '=> 462,' % '=> 797,' & '=> 710, ''' => 239,
'(' => 374, ')' => 374, '*' => 423, ''=> 605, ',' => 238, '-' => 375 ,'. '=> 238,'/'=> 334, '0' => 462, '1' => 462,
'2' => 462, '3' => 462, '4' => 462, '5' => 462, '6' => 462, '7' => 462, '8' => 462, '9' => 462, ':' => 238, ';' => 238,
'<' => 605, '=> 605,'> '=> 605 ,'? '=> 344,' @ '=> 748, 'a' => 684,' B '=> 560, 'C' => 695, 'D' => 739, & apos; E & apos; = & apos; 563 & apos,
'F' => 511, 'G' => 729, 'H' => 793, 'I' => 318, 'J' => 312, 'K' => 666, 'L' => 526, 'M' => 896, 'n' => 758, 'O' => 772,
'P' => 544, 'q' => 772, 'R' => 628, 's' => 465, 'T' => 607, 'U' => 753, 'V' => 711, 'W' => 972, 'x' => 647, 'y' => 620,
'Z' => 607, '[' => 374, ''=> 333, ']' => 374, '^' => 606, '_' => 500, ''' => 239, 'A '=> 417,' B '=> 503, 'C' => 427,
'D' => 529, 'E' => 415, 'F' => 264, 'G' => 444, 'H' => 518, 'I => 241, 'J' => 230, 'K' => 495, 'L' => 228, 'M' => 793,
'N' => 527, 'O' => 524, 'P' => 524, 'q' => 504, 'R' => 338,'s '=> 336, 'T' => 277, 'u' => 517, 'V' => 450, 'W' => 652,
'X' => 466, 'y' => 452, 'Z' => 407, '{' => 370, '|' => 258, '}' => 370 ,'~ '=> 605 );
Class performance_chinese extends FPDF
{
Function AddCIDFont ($ family, $ style, $ name, $ cw, $ CMap, $ registry)
{
$ I = count ($ this-> fonts) 1;
$ Fontkey = strtolower ($ family). strtoupper ($ style );
$ This-> fonts [$ fontkey] = array ('I' => $ I, 'type' => 'type0', 'name' => $ name, 'up' =>-120, 'ut' => 40, 'cw '=> $ cw, 'cmap' => $ CMap, 'registry' => $ registry );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.