I have a dynamic load from a MySQL database and my url is http: // localhost / far / contractview? ID = 137 . When I try to convert this page to a PDF file, I get a few errors, and I do not know what to do to convert this page to a PDF file with the click of a button.
I have included my code below. I am using mpdf .
<?php require("mpdf60/mpdf.php"); $mpdf=new mPDF('application/pdf','Letter-L','','',15,10,16,10,10,10);//A4 page in portrait for landscape add -L. $mpdf->debug = true; //$mpdf->allow_output_buffering = true; //$mpdf->SetHeader('|Your Header here|'); //$mpdf->setFooter('{PAGENO}');// Giving page number to your footer. $mpdf->useOnlyCoreFonts = true; // false is default $mpdf->SetDisplayMode('fullpage'); // Buffer the following html with PHP so we can store it to a variable later ob_start(); ?> <?php //include "contractview.php"; include_once "users.php"; //This is your php page ?> <?php $html = ob_get_contents(); ob_end_clean(); // send the captured HTML from the output buffer to the mPDF class for processing $mpdf->WriteHTML($html); //$mpdf->SetProtection(array(), 'user', 'password'); uncomment to protect your pdf page with password. $mpdf->Output(); exit; ?>
Thanks in advance.
source share