Dom PDF: PDF support for Smarty templates
Tuesday, May 19, 2009
I was having some troubles with PDF report generation. I used Smarty Templates, so I was looking for PDF class that will support Smarty output.
Finally I stayed on Dom PDF. It supports PHP 5 and CSS 2.1.
There are other options like set paper size etc. You can try this.
Finally I stayed on Dom PDF. It supports PHP 5 and CSS 2.1.
//include the dom pdf
require('dompdf/dompdf_config.inc.php');
//fetch the HTML output from smarty template
$htmlcontent=$smarty->fetch('smarty_template.tpl');
//call dom pdf class
$dompdf = new DOMPDF();
$dompdf->load_html($htmlcontent);
$dompdf->render();
//display output in browser
$dompdf->stream();
//or, save as a pdf
$pdf = $dompdf->output();
file_put_contents("tmp/filename.pdf", $pdf);
There are other options like set paper size etc. You can try this.
Post a Comment