i am trying to generate a pdf file from smarty template using dompdf:code is below:-
require_once(\'dompdf/dompdf_config.inc.php\');
$dompdf = new DOMPDF();
it works to me, at end my code looks like:
$html =
''.
'Put your html here, or generate it with your favourite '.
'templating system.
'.
'';
function pdf_create($html, $filename='', $stream=TRUE)
{
require_once('scripts/vendor/dompdf/dompdf/dompdf_config.inc.php');
$savein = '';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$canvas = $dompdf->get_canvas();
$font = Font_Metrics::get_font("arial", "normal","12px");
/*// the same call as in my previous example
$canvas->page_text(540, 773, "Page {PAGE_NUM} of {PAGE_COUNT}",
$font, 6, array(0,0,0));*/
$pdf = $dompdf->output(); // gets the PDF as a string
file_put_contents("arquivo.pdf",$pdf); // save the pdf file on server
unset($html);
unset($dompdf);
}
pdf_create($html);