6

I have a dynamic loading from MySQL DB, and my page URL is http://localhost/far/contractview?ID=137. When I am trying to convert this page to a PDF, I am getting a few errors, and I do not know what to do in order to convert this page to a PDF in a button click.

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.

Gerald Schneider
  • 17,416
  • 9
  • 60
  • 78
user2989676
  • 129
  • 3
  • 8
  • What are the "few errors" that you are getting? – bIgBoY Dec 14 '15 at 07:29
  • SCREAM: Error suppression ignored for Warning: include_once(contractview?ID=137) [function.include-once]: failed to open stream: Result too large in C:\wamp\www\far\php-to-pdf.php on line 15 – user2989676 Dec 14 '15 at 07:32
  • code of php-to-pdf.php is needed here. As you can see,you are trying to include a url and not a file. – bIgBoY Dec 14 '15 at 07:35
  • the above code is the code of php-to-pdf.php – user2989676 Dec 14 '15 at 08:23
  • 2
    The errors don't match your code `include_once "users.php";` is resulting in the error `include_once(contractview?ID=137)` ?? You can't include query string in `include` since an include is really just a copy and paste of the contents of the included php file. So that is the cause of the reported error, but it doesn't match the code you have provided. – Tristan Dec 14 '15 at 20:31
  • This thing is incoherent and overtagged. Not sure how it got 7 people voting it up. If you want help you need to provide more information and address @Tristan's very valid concerns. – miken32 Dec 16 '15 at 17:42

0 Answers0