Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

view pdf without downloading using dompdf

Tags:

php

pdf

dompdf

I generated a PDF using the dompdf library and used this:

$dompdf->stream('my.pdf',array('Attachment'=>0));

to force the browser to let the user view the PDF before downloading. But it's not working. A Google search isn't bringing up any answers either. Can anyone help?

like image 869
OJuice Avatar asked Jul 15 '14 05:07

OJuice


2 Answers

Try using the below code. Let me know are you create data from form or html file data.

$dompdf->stream("dompdf_out.pdf", array("Attachment" => false));

exit(0);
like image 170
Nithyanandhan M Avatar answered Oct 15 '22 03:10

Nithyanandhan M


If someone still looking for answer and it's still not resolved, try installing and turning on the PDF Viewer / PDF JS extension in the browser.

After adding parameter array(“Attachment”=>0) or array(“Attachment”=>false) to the stream and still not working. It's because your browser doesn't have a pdf reader available/activated. Installing and activating browser extension like PDF Viewer / PDFJS will force the browser to read and review the pdf.

like image 20
rozanfik Avatar answered Oct 15 '22 03:10

rozanfik