0

I am using MPDF Folder to generate a PDF file from HTML/PHP. This Generation of file is very helpful for many pages but now I am facing problem recently. In Mozila FireFox, when the pdf page is generated, IT is showing in the browser in complete format. After downloading/saving the file when I try to open it in Adobe reader, it shows me A message "Adobe Reader could not open 'mpdf.php' because it is either not a supported file type or because the file has been damaged". In Chrome , I get an error message as "Failed to load PDF document". However, in some other file file where PDF is generated, it works fine. I am not able to find the solution to this, so it would be very helpful to resolve this issue.
This is the below code which call the MPDF file to generate PDF

require("MPDF/mpdf.php");

$mpdf=new mPDF('c', 'A4');

$mpdf->WriteHTML($new);

$mpdf->Output();
9
  • Post a hexdump of the first Kilobyte or so of the downloaded file to make sure it is not your php source. And please remove the all caps from your title Commented May 2, 2016 at 7:04
  • seems you dowload the php file and not the pdf .. Commented May 2, 2016 at 7:07
  • @scaisEdge Downloaded format is PDF. As written, it opens in pdf for other files. But for one page, the format is not supporting. Commented May 2, 2016 at 7:09
  • make sure there is no echo,print before $mpdf->Output(); code Commented May 2, 2016 at 7:13
  • 1
    @Amlan it set header application/ pdf to send pdf to browser but if you echo something before it then that will also include in pdf content and it break your pdf Commented May 2, 2016 at 8:45

1 Answer 1

1

I had problems absolutely positioning a div. Displayed just fine in the browser but would not open in Adobe Reader. Reason: some warnings at beginning of generated pdf file. This fixed it for me: How to make mPDF 6.1 work with PHP 7.1.5 Basically, you have to change one line regarding the error reporting.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.