I used DOMPDF library and now I have problem with content with unicode language. and I found this one dompdf help but I don't understand about this. can anyone tell the detail of this? thanks
5 Answers
- Enable the mbstring extension
- Find a font in
.ttf
format with characters that support your given language - Generate a
.afm
file for DOMPDF:- Using the command line,
cd
into the directory which containsload_font.php
, then runphp load_font.php FontName /path/to/font.ttf
- Using the online tool, fill out the form and download the zip it gives you. Copy the files from this zip into
dompdf/lib/fonts
. If you've done this before, add relevant lines todompdf_font_family_cache
, otherwise simply rename thedompdf_font_family_cache.sample
todompdf_font_family_cache
- Using the command line,
Enable DOMPDF's Unicode mode, by making sure the line
define("DOMPDF_UNICODE_ENABLED", true);
is set in
dompdf_config.inc.php
. If it readsfalse
instead oftrue
, change that.
-
1I got message: Unable to locate the ttf2afm / ttf2pt1 executable (checked /home/piseth/dev/example/pdf_php/lib/ttf2ufm/ttf2ufm-src/ttf2pt1). Jan 23, 2012 at 9:32
-
Sounds like you need to install tt2afm or tt2pt1. Try ttf2pt1.sourceforge.net Jan 23, 2012 at 10:54
-
I tried your instruction, but it doesn't work. I read in another topic that I should add css about font family to the print.tpl and it really works then.– deemAug 6, 2013 at 13:07
-
-
1when i generate the pdf form html which contain burmese language( நான் என் முதலாளி வீட்டில் ஜன்னல்கள் வெளிப்புறம் சுத்தம் செய்ய தேவையில்லை என்று புரிந்துகொள்ளுங்கள் . ) then in pdf its show ??????????????????????????????????????????????? Mar 5, 2016 at 6:18
As of version 0.7, dompdf supports and has unicode enabled by default. (therefore there is no need for configuration).
Not all dompdf fonts support unicode though. I used font-family: DejaVu Sans
with success.
To install a custom font or learn more about it you can read the official unicode how to.
Download load_font.php and place in ur project root
View load_font.php
add $fontDir = "storage/fonts";
This will show where the fonts are added.
download your font at eg: PREETI and place at your project root
run in command line php load_font.php PREETI PREETI.ttf
then you font will be installed to storage/fonts
directory
now go to the pdf file and add
<style>
body {
font-family: PREETI;
color: #1c2221;
}
</style>
-
run in command line php load_font.php PREETI PREETI.ttf=>how do I run this ..command in browser or in php program ... I want to use in website pls help..command line is for window?..I wish to install for website Nov 5, 2022 at 19:12
try to manipulate your code using this recommended DOMPDF method
it's a A guide to enabling Unicode support in DOMPDF
To ensure maximum compatibility you should follow all of the following steps. Click through for additional details.
Ensure the MBString PHP extension is enabled
Install dompdf 0.6.0 or greater
Configure dompdf for Unicode support
Load a font supporting your characters into dompdf
Create a compatible HTML document
see the link for more information