Html 如何为 google chrome adobe pdf viewer 指定参数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7126089/
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 to specify parameters to google chrome adobe pdf viewer?
提问by BentOnCoding
I have an embed tag like this:
我有一个像这样的嵌入标签:
<embed src="../../Content/PDF/StockReport.pdf#zoom=50" width="100%" height="100%">
the #zoom=50 is a parameter that tells the pdf reader to zoom to 50%. This works in all browsers but google chrome because chrome has a built in pdf viewer.
#zoom=50 是一个参数,告诉 pdf 阅读器缩放到 50%。这适用于所有浏览器,但 google chrome 除外,因为 chrome 具有内置的 pdf 查看器。
How can I pass this same parameter to google chrome's pdf viewer ?
如何将相同的参数传递给 google chrome 的 pdf 查看器?
回答by BentOnCoding
After checking various chrome bug reports, I can confirm that Google Chrome ignores the default functionality of Adobe PDF viewer. At the time of this answer there is no way to pass parameters (like zoom) to the Chrome PDF viewer.
在检查了各种 chrome 错误报告后,我可以确认 Google Chrome 忽略了 Adobe PDF 查看器的默认功能。在此回答时,无法将参数(如缩放)传递给 Chrome PDF 查看器。
EDIT
编辑
Progress has been made on this by the Chromium team. The work was being done with reference to both the Acrobat SDKand RFC 3778. As of Dec 2017 Chromium added support for view
, zoom
, page
, toolbar
and nameddest
and later made it into Chrome.
Chromium 团队在这方面取得了进展。这项工作是参考Acrobat SDK和RFC 3778 完成的。截至 2017 年 12 月,Chromium 添加了对、、和 的支持view
,后来又加入了 Chrome。zoom
page
toolbar
nameddest
回答by damian1baran
Use iframe:
使用 iframe:
- It works in Mozilla
- It works in Chrome
- No Javascript needed
- 它适用于 Mozilla
- 它适用于 Chrome
- 不需要Javascript
Example:
例子:
<div id="mypdf">
<iframe src="/cennik.pdf#zoom=65" style="width: 100%; height: 800px;" frameborder="0" scrolling="no">
<p>Your web browser doesn't support iframes.</p>
</iframe>
</div>
回答by Matt Plank
It appears that a later release of Chrome may now be the answer. I had success passing zoom
and page
parameters through an object
tag.
现在看来,更高版本的 Chrome 可能就是答案。我通过标签成功传递zoom
和page
参数object
。
Case:
案件:
- Set zoom to 200%
- Set page to 2
- 将缩放设置为 200%
- 将页面设置为 2
Example:
例子:
<object data="https://your.url/docs/123.pdf#zoom=200&page=2"
type="application/pdf"
width="100%"
height="100%">
</object>