dompdf – The PHP 5 HTML to PDF Converter: Someone mentioned this over in the post on Prince. It looks quite good — they have a demo page where you can enter HTML in a box, then generate a PDF real-time. I tried it — it respects all CSS and generates a clean PDF.
Here’s some code, just to show how simple it is.
$html = "[an entire HTML document]"; $pdf = new DOMPDF(); $pdf->load_html($html); $pdf->render(); $pdf->stream("hello_world.pdf");
It’s free, and needs nothing but PHP5 and the DOM extension.