Squared characters issue on wkhtmltopdf

16,123

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
Share:
16,123
Tim Tuckle
Author by

Tim Tuckle

Updated on June 16, 2022

Comments

  • Tim Tuckle
    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
    Tim Tuckle over 13 years
    Yes, 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
    Elitmiar over 12 years
    The 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
    Marcin over 11 years
    Awesome solution James. Tim, please accept it as an answer as it clearly works.
  • Krishna Prasad Varma
    Krishna Prasad Varma about 11 years
    Excellent Answer. @Tim Tuckle: please accept this as the answer.
  • cassi.lup
    cassi.lup over 10 years
    Thank you! Worked like a charm in CentOS 6.5. @Tim Tuckle, please do accept the answer.
  • kodmasin
    kodmasin about 9 years
    Tnx! Solved my problem on CentOS 7.1
  • n0denine
    n0denine almost 9 years
    Thanks! Solved my issue. sudo yum install urw-fonts
  • a coder
    a coder over 8 years
    Solved my problem with wkhtmltopdf-amd running on RHEL7. Thanks!
  • a coder
    a coder over 8 years
    Basically 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
    a coder over 8 years
    This 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
    tmarois almost 8 years
    Awesome job! That was the solution on my end.
  • Ross The Boss
    Ross The Boss over 7 years
    Is there a ubuntu/debian equivalent to urw-fonts? -- this problem exists on ubuntu as well.
  • HartleySan
    HartleySan over 6 years
    This is THE answer!
  • ɹɐqʞɐ zoɹǝɟ
    ɹɐqʞɐ zoɹǝɟ over 6 years
    thanks 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
    sinhix almost 3 years
    Thanks ! I could not get the segmentation fault error !