5

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...

juanefren
  • 2,818
  • 6
  • 32
  • 41

1 Answers1

7

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.

cmc
  • 4,294
  • 2
  • 35
  • 34
  • All interested parties: Do notice that this makes your PDFs unsearchable where mysans is used. Also, it makes them bigger - a LOT bigger. My 1 page PDF grew from 38kb to 817kb. AND the result was actually not that great. While it did improve kerning, font weight and letter spacing issues a lot, sometimes the letters were still a little off horizontally - especially with number sequences. I suspect the letters get converted into images. – Joel Peltonen Jan 17 '14 at 13:47
  • @Nenotlep These issues did not affect me. – cmc May 27 '15 at 14:44
  • Good to hear. maybe I had a different version of wkhtmltopdf for example. There are still annoying font issues with 0.12.x.x, but all in all it's pretty good. My old project still uses the last 0.11.x release by Jakob because it seems to be allround the best one of the lot. I'm not working on it anymore though. Still a very useful answer as I think it relates even to the latest 0.12.x versions. – Joel Peltonen May 28 '15 at 11:08