Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mpdf not working in Google Chrome but working fine in firefox

Tags:

php

mpdf

Again am stuck into a situation while creating PDF document usong mPDF. I have done the following code which works fine in Firefox and Safari but not working in Google Chrome.

require_once 'mpdf60/mpdf.php';
$mpdf=new mPDF('c','A4','','' , 0 , 0 , 0 , 0 , 0 , 0); 

$mpdf->SetDisplayMode('fullpage');

$mpdf->list_indent_first_level = 0; 
$stylesheet = file_get_contents('css/style.css');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($test, 2);
$mpdf->Output();  

Can anyone please guide me on how to resolve this issue?

like image 461
Joyeeta Sinharay Avatar asked Mar 17 '23 01:03

Joyeeta Sinharay


1 Answers

According to your comment, try this before you send output:

ob_clean();
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $yourFileName . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');

require_once 'mpdf60/mpdf.php';
$mpdf=new mPDF('c','A4','','' , 0 , 0 , 0 , 0 , 0 , 0); 

$mpdf->SetDisplayMode('fullpage');

$mpdf->list_indent_first_level = 0; 
$stylesheet = file_get_contents('css/style.css');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($test, 2);
$mpdf->Output();  
ob_end_flush();
like image 160
szapio Avatar answered Mar 20 '23 05:03

szapio