Let TCPDF use Chinese fonts
IPFS
foreword
During the coding process, when encountering the need to contain Chinese in the TCPDF output PDF file.
Program
You can use the built-in method of TCPDF to convert Chinese fonts for TCPDF use.
If you don't have a complete TCPDF file, download it from https://github.com/tecnickcom/tcpdf
How to handle
- full download tcpdf
- Open the tools directory under tcpdf, and put the authorized Chinese fonts into this directory
- Use the following command to output the converted font
php tcpdf_addfont.php -i 中文字體.ttf
- After the output is successful, Process successfully completed!
- Switch to the upper directory to the fonts directory, and you can see the fonts after the conversion is successful
How to use
No more notes on how to use TCDPF, here only notes on how to use Chinese
$pdf->SetFont('轉換後中文字型', '字型風格', 字型大小);
$pdf->Text(x 座標, y 座標, '要輸出的變數或是內容');
Remark
Using this method to convert fonts, some True Type fonts fail to be converted, so you have to replace other fonts to use.
Link to the original text
Like my work? Don't forget to support and clap, let me know that you are with me on the road of creation. Keep this enthusiasm together!
- Author
- More