Condward
Condward

Reputation: 135

mPDF generated PDF is only working in Firefox

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

Answers (2)

redSaiyan
redSaiyan

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

Amit-Inex Patel
Amit-Inex Patel

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

Related Questions