Reputation: 135
So I was using the mPDF PHP library to generate a PDF using HTML code. I finished my code and then I realized that it only works in Firefox, for example in Chrome it displays 'Failed to load PDF document'.
Then I used the code from the examples instead of my own code and the same thing happens. Anyone knows how to solve this issue?
<?php
ob_start();
include('plugins/mpdf/mpdf.php');
$mpdf=new mPDF();
$mpdf->WriteHTML('<p>Hello World</p>');
$mpdf->Output();
exit;
?>
Upvotes: 1
Views: 4128
Reputation: 1
I had the same issue.I was adding header.php before calling mpdf.php and it did not work.After removing it is working fine.
Upvotes: 0
Reputation: 489
I have same issue but I got solution.. First remove ob_start(), and then put ob_clean() at that place.
ob_clean();
include('plugins/mpdf/mpdf.php');
$mpdf=new mPDF();
$mpdf->WriteHTML('<p>Hello World</p>');
$mpdf->Output();
exit;
Upvotes: 3