问题描述
我需要在HTML页面中嵌入PDF文件,以供用户在每个主要设备上查看.大多数方法在台式机上都可以正常工作,但在iPad设备上开始出现问题.如果将PDF放在iframe或嵌入标签中,则无法再滚动.
I need to embed a PDF file in an HTML page for the users to see it on every major device.Most of the approaches work fine on desktop but they start to show problems on iPad devices. The PDFs are no longer scrollable if placed inside an iframe or embed tag.
我使用以下技术来解决该问题:
I used the following techniques to overcome the problem:
1)使用 pdf-图像作为节点,然后将PDF转换为图像,然后在div中滑动它们.这种方法的问题是图像质量下降并且不适合在Web上查看.
1) Using pdf-image for node and converting the PDF to images and then sliding them in a div.The problem in this approach is that the image quality gets degraded and is not suitable for viewing on Web.
2)使用Mozilla的 PDF.js 它在所有设备上都能正常运行,但在iPad上使页面运行极其缓慢且无响应
2) Using PDF.js by MozillaIt works fine on every device but it makes the page extremely slow and unresponsive on iPad
3)使用Google PDF查看器
3) Using Google PDF viewer
<iframe src="https://docs.google.com/viewer?url=http://public-Url-of-pdf.pdf&embedded=true" frameborder="0" height="500px" width="100%"></iframe>
这种方法的问题是我需要公开公开我的PDF ,出于安全原因,我不想这样做.
The problem with this approach is that I need to make my PDFs publicly available which I don't want to do for security reasons.
以上方法均不适用于我.是否有任何解决方案可将PDF嵌入在iPad上也可使用的页面.
None of the above method is working for me. Is there any solution available to embed PDF in a page which works on iPad also.
我的一位同事告诉我有关使用 LibreOffice(无头开放式办公室)无头在页面中嵌入PDF的信息,但是我找不到有关其用法的任何文档吗?
One of my colleagues told me about using LibreOffice(open office) headless to embed PDFs in my page but I cannot find any documentation about it usage?
任何人都可以帮忙吗?:(
Can anyone please help? :(
提前谢谢!
推荐答案
<embed src="http://example.com/the.pdf" width="500" height="375" />
尝试以上一种方法获取纯 HTML
.但是另一个选择是,如果您想使用javascript,请尝试使用 mozilla
的 Pdf.js
. https://github.com/mozilla/pdf.js
Try above one for pure HTML
. But another option is if you'd like to use with javascript, try Pdf.js
by mozilla
. https://github.com/mozilla/pdf.js
这篇关于如何在PDF页面中嵌入PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!