Reputation: 141
I have a wierd problem. I'm developing an aplication that can create pdf files. The generating of pdfs works. But only on one site. If I first generate a pdf on the production it will work normally on production app but not on testing app. The opposite is also true. If I first create the pdf on the test it works normally on test but not on production. I'm 90% sure it's a browser issue. If I run the test and production on different browsers it works. The pruduction and test are on the same website but in different folders and have different databases and database users.
Production functions code for generating pdf
$pdf_name = $name.'.pdf';
ob_clean();
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $pdf_name . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
require_once 'pdf_templet.php';
$mpdf=new mPDF('utf-8','A4','','' , 0 , 0 , 0 , 0 , 0 , 0);
$mpdf->setFooter('{PAGENO}');
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0;
$mpdf->WriteHTML($html_pdf); //is generated in pdf_templet.php
$mpdf->Output($pdf_name,'I');
Testing functions code for generating pdf
$t = time();
$pdf_name = $name.'-'.$t.'.pdf';
ob_clean();
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $pdf_name . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
require_once 'pdf_templet.php';
$mpdf=new mPDF('utf-8','A4','','' , 0 , 0 , 0 , 0 , 0 , 0);
$mpdf->setFooter('{PAGENO}');
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0;
$mpdf->WriteHTML($html_pdf);
$mpdf->Output($pdf_name,'I');
In the testing function I added a timestamp to the name of the fileand the function has a different name, but it still doesn't work. Does some one know how to make it work?
Upvotes: 0
Views: 1938
Reputation: 141
The problem was that I was loading the mpdf wrong. I was using as it was on examples on their site before it was closed. The documentation at github explains it well.
I loaded it
require_once(mpdf/mpdf.php);
correct way is
require_once(mpdf/vendor/autoload.php);
Now it works! Thanks @KIKOSoftware that made me debug my code step by step.
Upvotes: 1