PDF Printing

Many websites need the functionality of creating pdf's using select data from a Drupal database. Monarch has implemented this capability on a number of sites. Here, we are featuring the processing we implemented for the  ILoveYouBills.com site.

For this site, we created the ability for bills to be printed as a pdf document by anyone who sets up an account and creates a bill. The pdf format was preferred as it can consistently render printed output across thousands of different printers, each with its own margins and printing style. Unlike an html page, pdf's are cross platform documents, but the challenge is providing a clear and concise workflow to produce a customized pdf document.

Monarch used wkhtmltopdf to generate the pdf's. When the pdf is created, a web browser using the webkit engine is opened in the background. The browser renders the formatted HTML code and the application uses the rendered output to generate a pdf file, which is then downloaded by the user. Unlike the contributed Drupal Print module, we needed to use a customized template that can only be modified by a system administrator.