Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Effective PDF Generation in Drupal
Feb 03, 2015 @ 15:43:53

On the SitePoint PHP blog today there's a new post showing you how to create PDFs in a Drupal-based site making use of the Print module for the creation and formatting.

DF generation takes a slight change of mindset. As web developers, we have spent a lot of time convincing designers from a print background to stop producing pixel perfect designs that will be difficult to reproduce on the web. If you want to introduce PDF generation or any form of high designed print output, then we need to relearn some of our old skills we left behind. The nature of print means that it is precise and often needs pixel (or millimeter) perfect design.

He'd initially thought that the Views PDF module would be the natural choice, but after finding some unwanted dependencies, opted for the Print module instead. The Print module only creates the formatted output, though. This is then passed off to wkhtmltopdf to convert into final PDF form. He walks you through the configuration for the Print module and how to create some of the basic HTML structure for the resulting output. Next up is the addition of some styling and the process for exporting the HTML output over to wkhtmltopdf for handling. Output samples are included to help illustrate the final result.

tagged: pdf generation drupal tutorial views print wkhtmltopdf convert

Link: http://www.sitepoint.com/effective-pdf-generation-drupal/

Marcus Bointon's Blog:
Compiling wkhtmltopdf on Mac OS X 10.7 Lion
May 16, 2012 @ 16:55:26

Marcus Bointon has written up the process he took to get the PHP extension for Wkhtmltopdf (a conversion tool for HTML to PDF generation) up and working on a Mac OSX machine - not as easy a task as it sounds.

Wkhtmltopdf is extremely cool. I’ve used qtwebkit for generating server-side page images before using python-webkit2png, and that’s fine (unlike using Firefox running in xvfb!), but I need to produce PDFs. So, I looked around and found several neat, simple PHP wrappers for calling wkhtmltopdf, and even a PHP extension. “Great”, I thought, “I’ll just install that and spend time working on the layouts since the code looks really simple”. I spoke too soon.

He goes through each step of the process - installing the needed wkhtmltox and libwkhtmltox support, having to manually compile wkhtmltopdf and some of the small changes you'll need to make to the Makefile to get things to cooperate. He shows where to put the resulting application files and the name of the extension to enable in your php.ini.

tagged: compile osx wkhtmltopdf problem manual

Link:

Perplexed Labs:
Convert HTML to PDF in PHP (libwkhtmltox extension)
Sep 16, 2010 @ 16:14:29

On the Perplexed Labs blog today Matt has this new post looking at a common issue developers face when they're trying to make their site easier for users to get their information off a site and onto their local machines - converting HTML over to PHP (using wkhtmltopdf).

Often this involves using somewhat cryptic output primitives and creating the PDF by hand. Wouldn't it be nice if there were a way to re-use all that beautiful HTML, CSS, and maybe even Javascript that you already wrote? Well, there is. It's called wkhtmltopdf. Normally a command line utility, with the release of 0.10.0_beta5 antialize included a simple C API to be able to build bindings in other popular languages.

How does this relate to PHP? Well, he's created an extension specifically to hook PHP into the tool and make calls like "wkhtmltopdf_convert" with the output type and page to convert as parameters and a PDF filename to push it out to.

tagged: wkhtmltopdf extension convert html pdf

Link:


Trending Topics: