Squared characters issue on wkhtmltopdf
Solution 1
When I had the black squares issue I was able to solve it without installing X11 by installing the urw-fonts package.
Solution 2
I was able to solve this problem using the following resource:
http://code.google.com/p/wkhtmltopdf/wiki/static
In short, you probably don't need to install the entire x11 library and all its dependencies. Just installing urw-fonts should do the trick. The above resource even mentions CentOS as having this problem.
Run this command on your server:
sudo yum install urw-fonts libXext openssl-devel
Solution 3
I am using CentOS 7 with wkhtmltox 12.4 and found that none of the suggestions thus far fixed my block-text in output PDFs.
For me, the final solution was to install dejavu-sans-fonts.
Solution 4
In case someone faces the same issue on Alpine. This solved the problem for me:
apk --update add ttf-dejavu
Tim Tuckle
Updated on June 16, 2022Comments
-
Tim Tuckle about 2 years
I've installed wkhtmltopdf on Centos 5.5. (Since there was library issues, it's been 4 days). It's partly working now. I said partly because, all pdfs which was created by wkhtmltopdf include squares instead of text?
What can I do? I've searched google, but I couldn't find anything.
Appreciate your help.
-
Tim Tuckle over 13 yearsYes, I tested as you have told the test.html. Even that one is displayed in squares. But all are filled with black. I tested wkhtmltopdf-i386 and wkhtmltopdf-amd64. I am afraid, my problem is so complicated. What do you think? :(
-
Elitmiar over 12 yearsThe solution from James F solved my problem. Had exact the same problem, when I execute the wkhtmltophp on the command line all fonts where 100%. But not if I try and execute it from PHP using the command. I run Centos 6 and installed URL fonts yum install urw-fonts and then it worked ;-) Thank you James
-
Marcin over 11 yearsAwesome solution James. Tim, please accept it as an answer as it clearly works.
-
Krishna Prasad Varma about 11 yearsExcellent Answer. @Tim Tuckle: please accept this as the answer.
-
cassi.lup over 10 yearsThank you! Worked like a charm in CentOS 6.5. @Tim Tuckle, please do accept the answer.
-
kodmasin about 9 yearsTnx! Solved my problem on CentOS 7.1
-
n0denine almost 9 yearsThanks! Solved my issue. sudo yum install urw-fonts
-
a coder over 8 yearsSolved my problem with wkhtmltopdf-amd running on RHEL7. Thanks!
-
a coder over 8 yearsBasically the same answer as James F. After downloaded the static binary I had to install the following deps to get it working on RHEL7:
yum install libXrender libXext fontconfig urw-fonts
-
a coder over 8 yearsThis is not true. If running EL7 you do not need the entire X11 system. Grab wkhtmltopdf-amd , then
yum install libXrender libXext fontconfig urw-fonts
-
tmarois almost 8 yearsAwesome job! That was the solution on my end.
-
Ross The Boss over 7 yearsIs there a ubuntu/debian equivalent to urw-fonts? -- this problem exists on ubuntu as well.
-
HartleySan over 6 yearsThis is THE answer!
-
ɹɐqʞɐ zoɹǝɟ over 6 yearsthanks mate , this one worked me after try so many damn number of suggestions/fixes/workarounds all over the internet so far. im on centos 7 and using wkhtmltopdf 0.12.2.1 (with patched qt)
-
sinhix almost 3 yearsThanks ! I could not get the segmentation fault error !