Html 如何嵌入PDF?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14690000/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:24:55  来源:igfitidea点击:

How to embed a PDF?

htmlpdf

提问by John Foley

I am trying to embed a PDF in an HTML document, but this seems to work only with Chrome. Other browsers appear to either require plugins or require a user to click a link which is not what I want. Here is what I have tried:

我试图在 HTML 文档中嵌入 PDF,但这似乎只适用于 Chrome。其他浏览器似乎要么需要插件,要么需要用户点击一个不是我想要的链接。这是我尝试过的:

<object data="pdfFiles/interfaces.pdf" type="application/pdf">
    <embed src=" pdfFiles/interfaces.pdf" type="application/pdf">&nbsp;</embed>
                    alt :<a href="pdfFiles/interfaces.pdf">
</object>

回答by Vuk Vasi?

Here is the code you can use for every browser:

这是您可以用于每个浏览器的代码:

<embed src="pdfFiles/interfaces.pdf" width="600" height="500" alt="pdf" pluginspage="http://www.adobe.com/products/acrobat/readstep2.html">

Tested on firefox and chrome

在 Firefox 和 chrome 上测试

回答by John Foley

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

Google docs allows you to embed PDFs, Microsoft Office Docs, and other applications by just linking to their services with an iframe. Its user-friendly, versatile, and attractive.

Google docs 允许您通过 iframe 链接到他们的服务来嵌入 PDF、Microsoft Office Docs 和其他应用程序。其用户友好、通用且有吸引力。

回答by fuddin

This works perfectly and this is official html5.

这完美地工作,这是官方的 html5。

<object data="https://link-to-pdf"></object>

回答by Herbert Pimentel

do you know about http://mozilla.github.io/pdf.js/it is a project by mozila to render pdf inside of your html using canvas. it is super simple to use.

你知道http://mozilla.github.io/pdf.js/它是 mozila 的一个项目,它使用画布在你的 html 中渲染 pdf。使用起来非常简单。

回答by Chris Peters

I recommend using PDFObjectfor PDF plugin detection.

我建议使用PDFObject进行 PDF 插件检测。

This will only allow you to display alternate content if the user's browser isn't capable of displaying the PDF directly though. For example, the PDF will display fine in Chrome for most users, but they will need a plugin like Adobe Reader installed if they're using Firefox or Internet Explorer.

如果用户的浏览器无法直接显示 PDF,这将只允许您显示替代内容。例如,对于大多数用户来说,PDF 可以在 Chrome 中正常显示,但如果他们使用 Firefox 或 Internet Explorer,则需要安装 Adob​​e Reader 等插件。

At least PDFObject will allow you to display a message with a link to download Adobe Reader and/or the PDF file itself if their browser doesn't already have a PDF plugin installed.

如果他们的浏览器尚未安装 PDF 插件,至少 PDFObject 将允许您显示一条消息,其中包含下载 Adob​​e Reader 和/或 PDF 文件本身的链接。

回答by Rob Z

FlexPaper is probably still the best viewer out there to be used for this kind of stuff. It has a traditional viewer and a more turn page / flip book style viewer both in flash and html5

FlexPaper 可能仍然是用于此类内容的最佳查看器。它有一个传统的查看器和一个更多的翻页/翻书风格的查看器,包括 flash 和 html5

http://flexpaper.devaldi.com

http://flexpaper.devaldi.com