'In mpdf to Output a pdf file to a Browser
I am trying to view the pdf file created using mpdf. On using the command as
$pdf = $mpdf->Output('mep.pdf','I');
the pdf gets downloaded rather. Although, I: send the file inline to the browser. The plug-in is used if available. The name given by filename is used when one selects the "Save as" option on the link generating the PDF.
I would like to view the pdf in the browser and depending on the user choice to download it, print it or just view it and exit.
Kindly help. Thanks.
Solution 1:[1]
It depends on the browser whether it can and will display PDF files inline. But to help it a little you should at least tell the browser that it's a PDF file. You can do this by sending a content-type header:
header('Content-Type: application/pdf');
This line should be executed before sending the PDF contents.
Solution 2:[2]
You can use this. May be it will help you.
include file:
include_once './mpdf/mpdf.php';
create object of mpdf:
$pdf =new mPDF("","A4","","",10,10,10,10,6,3);
$mpdf->WriteHTML('Text which you want in PDF file');
$pdf->Output('filename.pdf','I');
Still not able to view file:
define content type of header
header('Content-Type: application/pdf',charset=utf-8');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | GolezTrol |
Solution 2 | Nidhi |