Showing posts from May, 2012

Wkhtmltopdf font and sizing issues

Wkhtmltopdf does a pretty good job at converting HTML documents to PDF. It does have a few oddities however when it comes to getting consistent font sizing. Namely, you may find that the tool generates PDFs at different scales on different computers. So for example, everything looks right on your development machine, but when you deploy to a test server or production, everything looks like it's zoomed in.

I haven't read enough about it's architecture to know how it works exactly, but I believe it takes the HTML input and passes it to a WebKit rendering engine, which actually renders the HTML to some virtual or hidden browser window, and then it simply prints the state of that browser window to PDF using a QT driver.

Just like a real browser window though, unless you specify exact fixed widths for your HTML containers, the contents will get wrapped to try and fit without any horizontal scrolling. The default width of this internal browser is dependent on the resolution of y…

Google's Language Immersion for Chrome

If you've been putting off learning a new language, or have forgotten everything you've learnt from lack of practice, then the Language Immersion for Chrome extension is just what you need!

The tool is simple: you pick a language that you want to practice and a level of difficulty. Then for every web-page you visit, it will pick out a few random words and replace them with equivalent translations in the chosen language. You can hover your mouse over these words to hear an immediate pronunciation, or you can click on them to convert them back into the original language. The level of difficulty controls the frequency of translated words, so at novice level, it will translate say three words per paragraph. At expert level, it will translate a lot more.

This is a fantastic idea, as you can multi-purpose your time spent on the internet. So whenever you take those 30 minutes in the morning to catch up on your favourite news blogs, turn this thing on and learn a foreign language at t…

Server-side HTML to PDF Converter

A common requirement of many document-based web-applications is the ability to generate a PDF document from dynamic content. There are two main methods for doing this:

Use a raw PDF library such as Zend_PDF and write the complex logic needed to format a PDF from scratch;Use a library that can convert a HTML-formatted document to PDF. Option number two is by far the easiest path, especially since your web-framework already has all the libraries and modules required to render dynamic content into appropriate views. So you basically just create a new web-page which is formatted the way you want your PDF to look, then pass this URL to a converter that renders this HTML to a PDF file.
There are many different libraries that do this. Some can be integrated directly into your web-app (depending on the language that you're using), while others are stand-alone command-line tools which can be invoked from any process.
The key features to look for when picking one of these html-to-pdf convert…