문제

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.

도움이 되었습니까?

해결책

When I had the black squares issue I was able to solve it without installing X11 by installing the urw-fonts package.

다른 팁

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

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.

I'm going to guess this is a font issue, or perhaps an encoding issue.

What encoding does your HTML use? (This is easier to check so I listed it first) If it's something funky, you might have to translate it prior to feeding it to wkhtmltopdf. Reporting a bug might help too in this case.

Does wkhtmltopdf know how to find your fonts? If wkhtmltopdf can't find your system's fonts, then it's got a serious problem and might fall back on the "Unknown Character" character (the empty box).

Also, if your text contains characters that don't actually exist in the requested font, you'll get the unknown character character. If you're supposed to be using "Courier New" and the text is all Arabic... the font courier doesn't contain those characters. Browsers have various fall-back positions they can use, but a PDF renderer will just do what it's told to the best of its ability. And in this case, that's the unknown character character.

Simple Test: can wkhtmltopdf successfully convert a "hello world.html" to PDF on your system?

<html><body>Hello World</body></html>

If that works, you need to figure out where along the line between "brain dead" and "your real html" Things Go Awry.

I think you need to try to install the X11 packages, wkhtmltopdf uses that for fonts etc. The symptoms you describe are exactly what the program would do with those packages missing.

The standalone wkhtmltopdf does not need an x-server - try it and see if that alleviates the problem. I have it working on CentOS with no graphics/x-server and it works absolutely fine.

In case someone faces the same issue on Alpine. This solved the problem for me:

apk --update add ttf-dejavu
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top