开发者

Show PDF in a web

开发者 https://www.devze.com 2022-12-29 11:19 出处:网络
I want to dis开发者_如何学编程play the contents of PDF file in a webpage. I don\'t want the browser to download when the user clicks.Use the Google PDF Viewer:

I want to dis开发者_如何学编程play the contents of PDF file in a webpage. I don't want the browser to download when the user clicks.


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>


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号