Can someone put together a clear and concise example of how you can create a PDF using TCPDF that will support text strings from any language?
It appears there is not a single font that will support all languages. I'm guessing the font would be too large?
I assume the correct way would be to detect the language of the string and dynamically set the font type to a compatible font. If this is the case then it gets very complex in detecting the language for each string.
Most languages are supported if you use the "freeserif" font. However it does not support CJK fonts. I've tried many fonts (kozminproregular, cid0jp, cid0kr, cid0jp, stsongstdlight) to get support for Chinese, Japanse, and Korean, but none of them seem to support all three languages.
This worked out perfectly for me. Thank you!
To make sure, the generated PDF file will not get to big, use FontSubsetting - I have a 10 page PDF generated with only a few Lines of chinese (Names on Diplomas)
$pdf->setFontSubsetting(true); => PDF File slightly bigger 925kb vs 755kb without the chinese names if you use $pdf->setFontSubsetting(false); => PDF File size as about 17.5 MB ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With