tags:

views:

53

answers:

4
+1  Q: 

Show PDF in a web

I want to display the contents of PDF file in a webpage. I don't want the browser to download when the user clicks.

+1  A: 

You could embed the adobe acrobat plugin inside your markup. Of course the user must have installed some the appropriate plugin in his browser for this to work. Another possibility is to set your server side script to send proper HTTP headers to instruct the browser embedding the file.

Darin Dimitrov
The world needs less companies stomping into browsers.
msw
The world needs less browsers too :-)
Darin Dimitrov
+1  A: 

You aren't going to be able to control the browser config from the server side. Some people's browsers will be configured to show PDFs inline, and others won't.

What you can do (reading this as a programming question) is to convert the PDF to HTML and deliver the results. Apache PDFBox might prove useful for such an effort.

bmargulies
A: 

Use an <iframe>.

<iframe src="/url/to/file.pdf" width="500" height="300"></iframe>

Or an <object> when you're actually using XHTML.

<object data="/url/to/file.pdf" type="application/pdf" width="500" height="300">
    alt : <a href="/url/to/file.pdf">file.pdf</a>
</object>

Note that the above is not supported by the ancient browsers, the above construct would let them degrade gracefully to a plain vanilla link.

BalusC
+4  A: 

Use the Google PDF Viewer:

<iframe src="http://docs.google.com/gview?url=URL_TO_YOUR_PDF&amp;embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>
webdestroya
That's a pretty cool trick!
Barry Brown
Indeed :) It is quite useful rather than forcing the user to run the PDF
webdestroya
Alec
Yea, but like you said there are ways around that. You can even make a single-use key or something, that once the file is read thru Google, it will expire the link.
webdestroya