在 div 中显示 Adobe pdf
我有一个 pdf 文件,用户必须查看该文件并单击“我同意”按钮。 如何在 div 中显示 pdf?
I have a pdf file that the user has to see and click on the "I agree" button.
How do you display a pdf inside a div?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
是的,你可以。
请参阅 2007 年以下线程中的代码:DIV 内的 PDF
使用
(最后,我编辑了我的 pdf 文件以删除大边框并将它们转换为到 jpg 图像。)
Yes you can.
See the code from the following thread from 2007: PDF within a DIV
It uses
<object>
, which can be styled with CSS, and so you can float them, give them borders, etc.(In the end, I edited my pdf files to remove large borders and converted them to jpg images.)
这是使用 Iframe 在 Div 中显示 PDF 的另一种方法,如下所示。
Here is another way to display PDF inside Div by using Iframe like below.
我们在我们的网站上使用它
http://issuu.com/smartlook
它是一个非常可定制的直接显示 PDF您的浏览器。如果您不反对这种事情,它基本上将 PDF 托管在 Flash 对象中。
这是我们公司网站上的示例。
We use this on our website
http://issuu.com/smartlook
Its a very customizable to display PDF's directly in your browser. It basically hosts the PDF in a flash object if you are not opposed to that sort of thing.
Here is a sample from our corporate website.
您可以使用 Javascript 库 PDF.JS 在 div 内显示 PDF。 PDF的大小可以根据div的大小进行调整。您还可以设置事件处理程序以移至 PDF 的下一页/上一页。
您可以查看 PDF .JS 教程 - 如何使用 Javascript 显示 PDF 以了解如何将 PDF.JS 集成到您的 HTML 代码中。
You can use the Javascript library PDF.JS to display a PDF inside a div. The size of the PDF can be adjusted according to the size of the div. You can also setup event handlers for moving to next / previous pages of the PDF.
You can checkout PDF.JS Tutorial - How to display a PDF with Javascript to see how PDF.JS can be integrated in your HTML code.
我认为它不起作用,因为您的 z-index 属性未应用于 pdf(任何外部对象)。因此,当您在 PDF 视图边界中添加任何控件时,它会出现在 pdf 视图的后面。
I think its not working, because you z-index property not applied on pdf(any outside object). So when you add any control in PDF view boundary,its appear behind of pdf view.
您可以创建一个图像缩略图,并使用类似的内联弹出窗口将其链接到实际的 pdf
http://orangoo.com/labs/GreyBox/
You could create an image thumbnail, and link it to the actual pdf as an inline popup using something like
http://orangoo.com/labs/GreyBox/
也许你可以使用 AJAX 或 jquery 来完成...
只需在一页上发送该文件 url,然后像在该页面中正常打开 pdf 文件一样打开并使用 ajax。
1) 一旦用户单击按钮。然后你调用你上面的函数。因此,通过这种方式,将只有一页,这样您就可以显示尽可能多的 pdf,而无需刷新页面。
2) 如果您没有很多 pdf 文件并且您不知道,则只需将该文件上传到 google文档
然后只需放置共享链接文件......然后只需使用ajax或jquery。
如果你没有使用 AJAX,我更喜欢 jquery。
may be you can do by using AJAX or jquery...
just send that file url on one page and then open like normally open pdf file in that page and use ajax.
1)so as soon as user will click on the button. then u call that function in which u above tast. So by this way there will be only one page and by that you can show as many pdf without refreshing page.
2) if u don't have many pdf and if u don't know then just upload that file on google docs
and then just put the share link file....and then just use ajax or jquery.
i prefer jquery if u don't have use AJAX.
你不能,这是简单的答案。
进入浏览器的每个媒体资产都由 mime 类型名称来标识。然后浏览器根据该 mime 类型名称做出处理决定。如果是 image/gif 或 image/jpeg,浏览器会将资源作为图像处理。如果它是 text/css 或 text/javascript,则它会作为代码资产进行处理,除非该资产的寻址独立于 HTML。 PDF 被识别为 application/pdf。当浏览器看到 application/pdf 时,它们会立即将处理切换到能够处理该媒体类型的插件软件。如果您尝试将 application/pdf 类型的媒体推送到 div 中,浏览器可能会向用户抛出错误。通常,application/pdf 类型的文件直接链接,以便处理软件拦截请求并独立于浏览器处理媒体。
You cannot, and here is the simple answer.
Every media asset poured into the browser is identified by a mime type name. A browser then makes processing determinations upon that mime type name. If it is image/gif or image/jpeg the browser processes the asset as an image. If it is text/css or text/javascript it is processed as a code asset unless the asset is addressed independent of HTML. PDF is identified as application/pdf. When browsers see application/pdf they immediately switch processing to a plugin software capable of processing that media type. If you attempt to push media of type application/pdf into a div the browser will likely throw an error to the user. Typically files of type application/pdf are linked to directly so that the processing software an intercept the request and process the media independent of the browser.
我认为你不能。您可能需要使用 Iframe。
I don't think you can. You may need to use an Iframe instead.