Html 如何在显示所有 pdf 页面的 iframe 中显示 pdf?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14940779/
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
How do I display a pdf inside an iframe showing all pdf pages?
提问by Y_Y
I've been working on having multiple pdf documents inside a single html page using iFrames. I figured how to insert pdfs inside iFrames but I've been curious if it's possible to add a pdf to an iFrame while showing all the pdf pages; that is, the iframe should display all the pdf content without a vertical scroll bar.
我一直在使用 iFrame 在单个 html 页面中处理多个 pdf 文档。我想出了如何在 iFrame 中插入 pdf,但我很好奇是否可以在显示所有 pdf 页面的同时将 pdf 添加到 iFrame;也就是说,iframe 应该显示没有垂直滚动条的所有 pdf 内容。
Thanks, Y_Y
谢谢,Y_Y
采纳答案by Tanner
<iframe src="mydoc.pdf" width="100%" height="800px"></iframe>
I don't think you can show all pages, unless you make the height property large enough to show all pages. You would have to make the height big enough (proportionally) to show all pages based on the width of the iframe.
我认为您不能显示所有页面,除非您将 height 属性设置得足够大以显示所有页面。您必须使高度足够大(按比例)以根据 iframe 的宽度显示所有页面。
回答by Muddasir Abbas
IFRAME
框架
<iframe id="fred" style="border:1px solid #666CCC" title="PDF in an i-Frame" src="PDFData.pdf" frameborder="1" scrolling="auto" height="1100" width="850" ></iframe>
Object
目的
<object data="your_url_to_pdf" type="application/pdf">
<embed src="your_url_to_pdf" type="application/pdf" />
</object>