Arsalan
Arsalan

Reputation:

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.

Upvotes: 1

Views: 437

Answers (4)

BalusC
BalusC

Reputation: 1108567

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.

Upvotes: 0

Mitch Dempsey
Mitch Dempsey

Reputation: 39869

Use the Google PDF Viewer:

<iframe src="http://docs.google.com/gview?url=URL_TO_YOUR_PDF&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>

Upvotes: 5

bmargulies
bmargulies

Reputation: 100003

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.

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

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.

Upvotes: 1

Related Questions