2

I am done with generating PDF file using FPDF in php. But the problem is how to open this pdf without the Save As option? I want to display the pdf document in the browser.

Havelock
  • 6,913
  • 4
  • 34
  • 42
nonadia
  • 49
  • 3
  • 4
  • please note fpdf has not been updated for a while, tcpdf on the other hand has ;) – Rene Pot Sep 04 '12 at 08:35
  • I guess this is a browser problem not due to fpdf? – jtheman Sep 04 '12 at 08:35
  • possible duplicate of [How to force PDF files to open in browser?](http://stackoverflow.com/questions/6293893/how-to-force-pdf-files-to-open-in-browser) – JJJ Sep 04 '12 at 08:46

7 Answers7

6

http://www.fpdf.org/en/doc/output.htm

Syntax: Output([string name] , string dest) , use I as Destination and fdpf will try to show it in the browser, if browser plugings and so on enable it

Dukeatcoding
  • 1,363
  • 2
  • 20
  • 34
1

You cannot force this display, as it is up to the user to choose to display the PDF inline or systematically save them. I prefer the second option...

Now, there is a JavaScript / HTML 5 project (experimental!) to display PDF without plugin, so perhaps you can try that.

PhiLho
  • 40,535
  • 6
  • 96
  • 134
1

Even when using fpdf passing the output to the browser, I believe its still up to the user if they open or save it.

A solution would be to use some kind of PDF viewer, for example http://view.samurajdata.se/

Nick
  • 6,316
  • 2
  • 29
  • 47
1

Try this $pdf->Output('I', 'filename.pdf')

See the reference http://www.fpdf.org/en/doc/output.htm

Rafiq
  • 86
  • 1
  • 8
0

Set header's content-type to 'application/pdf'. Then, most browsers will try to open it and show in-browser (or at least ask user to save or open file)

Alex Chorry
  • 334
  • 4
  • 9
0

Try echoing the PDF instead to using header function. The header function will force the browser to download. The echo 'might' show the pdf.

Bijoy Thangaraj
  • 5,434
  • 4
  • 43
  • 70
Jimmy Obonyo Abor
  • 7,335
  • 10
  • 43
  • 71
0

Your browser must have pdf plugin installed. If you havent done so install latest version of Acrobat Reader. If you are using fpdf, output the string instead of forcing download For details

http://www.fpdf.org/en/doc/output.htm
WatsMyName
  • 4,240
  • 5
  • 42
  • 73