Html 有没有办法将pdf文件嵌入到html5页面中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3113334/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there any way to embed a pdf file into an html5 page?
提问by Catia
I want to have a web page coded with HTML5, and I want to be able to put a pdf file onto this page so you can view it without having to click on any links to download it separately. Anyone know how to do this? I want it to keep the text, images, and layout of the pdf file also. If that weren't the case I would just use an image. Thanks!
我想要一个用 HTML5 编码的网页,并且我希望能够将一个 pdf 文件放在这个页面上,这样你就可以查看它而无需单击任何链接来单独下载它。有人知道怎么做吗?我希望它也保留 pdf 文件的文本、图像和布局。如果不是这种情况,我只会使用图像。谢谢!
Edit: This will be hopefully going onto the ipad. So it won't support adobe. I need to just find a way to somehow make the pdf file show up in an html5 page without using a viewer. I want to keep all of its layers. It doesn't have to stay a pdf file when its on the page, I just need to find a way to transfer all of those layers there without having to do this manually with divs for each image, paragraph, etc.
编辑:这将有望进入 ipad。所以它不会支持adobe。我只需要找到一种方法,以某种方式使 pdf 文件显示在 html5 页面中,而无需使用查看器。我想保留它的所有层。当它在页面上时,它不必保留一个 pdf 文件,我只需要找到一种方法来将所有这些图层传输到那里,而不必使用每个图像、段落等的 div 手动执行此操作。
回答by alecwh
I don't think this is possible without using Flash. Instead, you might want to convert the PDF to a different format (HTML for example) that can be rendered by the browser. There are tools that can do this from the command line, so making a script to do it on your site won't be too difficult.
我认为如果不使用 Flash,这是不可能的。相反,您可能希望将 PDF 转换为浏览器可以呈现的不同格式(例如 HTML)。有一些工具可以从命令行执行此操作,因此编写脚本在您的站点上执行此操作不会太困难。
回答by chrisbjr
You can use the embed tag like this:
您可以像这样使用 embed 标签:
<embed src="/path/to/your/file.pdf" />
回答by Alex
Maybe you could convert the pdf to images on the server and display the images instead of the original pdf. As far as i know, Apache pdfbox can be used to do such a convert.
也许您可以将 pdf 转换为服务器上的图像并显示图像而不是原始 pdf。据我所知,Apache pdfbox 可以用来做这样的转换。
回答by Juan
A little bit late and maybe issuu is gonna fix it soon but for now you can embed with issuu.com using an iframe and your magazine address ending in ?mode=mobile. Tested in ipad:
有点晚了,也许 issuu 很快就会修复它,但现在您可以使用 iframe 嵌入 issuu.com,并且您的杂志地址以 ?mode=mobile 结尾。在ipad上测试:
<iframe width="850px" height="580px" src="http://www.issuu.com/your_username/docs/your_magazine_name?mode=mobile" frameborder="0" allowfullscreen></iframe>
I would like same mobile version loading in desktop so there is no advertising. If you know how to make the browser to think it's an ipad let me know.
我希望在桌面上加载相同的移动版本,因此没有广告。如果您知道如何让浏览器认为它是 ipad,请告诉我。
回答by user3702247
This code would directly embed a pdf viewer in a webpage
此代码将直接在网页中嵌入 pdf 查看器
<object data="path to pdf " type="application/pdf" width="100" height="100">
<p>Alternative text - include a link <a href="path to pdf">to the PDF!</a></p>
</object>
回答by userx
If you are using ASP.NET, this linkmay be of interest to you.
如果您使用的是 ASP.NET,您可能会对这个链接感兴趣。
Browser Based PDF Viewing And Editing Hosted entirely on your server, activePDF Portal is an ASP.NET WebControl that enables your users to interactively view and modify PDF documents from any source - adding comments, form fields, bookmarks, and more – directly from within a standard web browser, without requiring any client-side software such as Adobe Reader or Flash, or the use of ActiveX controls. - http://portal.activepdf.com/
基于浏览器的 PDF 查看和编辑完全托管在您的服务器上,activePDF Portal 是一个 ASP.NET Web 控件,它使您的用户能够交互式地查看和修改来自任何来源的 PDF 文档 - 添加注释、表单域、书签等 - 直接从一个标准 Web 浏览器,无需任何客户端软件,如 Adobe Reader 或 Flash,或使用 ActiveX 控件。- http://portal.activepdf.com/