Showing posts with label Dom PDF. Show all posts
Showing posts with label Dom PDF. Show all posts

Tips for Dom PDF

Tuesday, May 19, 2009 Posted by Md. Monjurul Hasan 0 comments
See what I have experienced so far. May be useful for you too.

  1. No need to install, can be called directly.But be sure php-xml package is installed. You can be sure from phpinfo().

  2. When using, change the path in dompdf_config.inc if necessary

  3. Be sure that the html code is clean i.e. tags are closed

  4. Dom PDF can not render multiple html pages with a single table. I was facing of getting a single page while original was more than one


To be continued....
Labels:

Dom PDF: PDF support for Smarty templates

Posted by Md. Monjurul Hasan 0 comments
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.


//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.
Labels: ,