Take the 2-minute tour ×

A client of mine has a food blog hosted on WordPress. Each post entry contains some text and a div called "recipes" with some more text inside it. They would like to add to this div a link that generates a PDF of the recipe, dynamically, for saving or printing, as the user sees fit.

I have seen quite a few Wordpress plugins that offer the conversion of entire posts to PDF but not anything that's customizable enough to select a given portion of a post, the way we'd like to.

Any suggestions on how to do this? I'm comfortable with PHP, Javascript, CSS but am new to the various PDF libraries.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Take a look at dompdf It's pretty easy to work with :) This is from the documentation:


$html =
  '<p>Put your html here, or generate it with your favourite '.
  'templating system.</p>'.

$dompdf = new DOMPDF();
share|improve this answer
I'm not sure how to use this but I posted a related question here. Any help would be appreciated. –  Isaac Lubow Jan 25 '11 at 4:09
Would you mind just marking this as answered? :D –  simme Jan 29 '11 at 0:15
add comment

If you need more control than dompdf you could always use PHP's XML/XSL methods to convert the HTML to XSL:FO and use FOP on the commandline to generate the PDF. It's a little long-winded but you get complete control of the output styling/structure, the ability to "lock" the PDF, provide metadata, etc.

share|improve this answer
add comment

Your Answer


