Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wkhtmltopdf font size increased after update

I just updated wkhtmltopdf from 0.9.9 to 0.11.0 rc1 (downloaded the binary and just moved to /usr/bin/wkhtmltopdf-new having in /usr/bin/wkhtmltopdf the one from repositories)

If I run /usr/bin/wkhtmltopdf-new I get very large fonts as results/ If I run /usr/bin/wkhtmltopdf I get the normal results.

Example using the same HTML This is a document with 0.9.9 http://dl.dropbox.com/u/1990697/0.9.9.pdf The same document with 0.11.0 rc1 http://dl.dropbox.com/u/1990697/0.11.0.pdf

I want to reach the result I had with 0.9.9

Any ideas?

Cheers...

like image 789
juanefren Avatar asked May 09 '12 00:05

juanefren


1 Answers

Apparently, this is an issue with QT that could take a while to fix.

A workaround has been to use OTF format fonts.

@font-face {
    font-family: 'mysans';
    src: url(/path/to/myfont.otf);
}

Finally, there is an online service to convert TTF fonts into OTF fonts.

So the best workaround for now seems to be: Get your font as a TTF, convert it to OTF with the mentioned service, and use it as specified above.

In one application, I am both delivering HTML to the browser, and rendering it as PDF. In this case, I am using some server side logic to generate one web font tag with WOFF to deliver to the browser, and one web font tag with OTF to deliver to wkhtmltopdf.

The reason OTF fonts work is that they are embedded more or less as-is in the PDF, and the QT bug is related to rendering non-OTF fonts into the PDF.

like image 94
cmc Avatar answered Sep 29 '22 12:09

cmc