[英]How to change the browsers' pdf viewer through program (e.g. HTML, JS, PHP )?
Goal : A browser base pdf viewer that has zoom and drag/ pan function (better if allow hiding the save function) to replace the browser default one 目标:具有缩放和拖动/平移功能的浏览器基础pdf查看器(如果允许隐藏保存功能,则更好)替换浏览器默认值
Problem : all browser (exclude old IE) has their own build in pdf viewer, that without dragging/pan function 问题:所有浏览器(不包括旧的IE)在pdf查看器中都有自己的构建,没有拖动/平移功能
Currently this code use default pdf viewer: 目前此代码使用默认的pdf查看器:
<object id = 'zoomPage' type='application/pdf' data= '1.pdf'>
<p>The PDF can not display
</p>
</object>
Is it possible to force all browser (Chrome , FireFox , IE8+) using the adobe reader to open pdf file using javascript / jquery / html /php? 是否可以使用adobe reader强制所有浏览器(Chrome,FireFox,IE8 +)使用javascript / jquery / html / php打开pdf文件? Or are there any web base pdf viewer has the functions mentioned above?
或者有任何网络基础pdf查看器具有上述功能?
Note: 注意:
For the first approach : 对于第一种方法:
I found the way eg content-disposition : attachment 我找到了例如内容处理的方式:附件
but it only change the behavior from viewing to download the pdf , not changing the preference in opening the pdf file 但它只会改变从查看下载pdf的行为,而不是更改打开pdf文件的首选项
For approach 2: (Which I recommend) Check out: 方法2 :(我推荐)查看:
https://github.com/mozilla/pdf.js/
PDF.js is Portable Document Format (PDF) viewer that is built with HTML5.
PDF.js是使用HTML5构建的可移植文档格式(PDF)查看器。
PDF.js is community-driven and supported by Mozilla Labs.
PDF.js由社区驱动,并由Mozilla Labs提供支持。 Our goal is to create a general-purpose, web standards-based platform for parsing and rendering PDFs.
我们的目标是创建一个通用的,基于Web标准的平台,用于解析和呈现PDF。
EDIT: For your speed needs, check the discussion on the other options here: Recommended way to embed PDF in HTML? 编辑:为了您的速度需求,请在此处查看其他选项的讨论: 在HTML中嵌入PDF的推荐方法? and see if the other options fit your requirements.
并查看其他选项是否符合您的要求。
Approach 1 is inherently dicey due to security reasons 由于安全原因,方法1本身就是冒险的
The only way you can force it client-side is by supplying the alternative...such as pdf.js, zoho, google pdf viewer, scribd, etc (there are many). 你可以强制客户端的唯一方法是提供替代方案......例如pdf.js,zoho,google pdf viewer,scribd等(有很多)。 I'm not sure if Adobe provides an in-browser pdf viewer like you're expecting.
我不确定Adobe是否提供了您期望的浏览器内pdf查看器。
The default pdf viewer is kept in a variable found in about:config that can only be changed by the user. 默认的pdf查看器保存在about:config中的变量中,该变量只能由用户更改。
Is it possible to force all browser (Chrome , FireFox , IE8+) using the adobe reader to open pdf file using javascript / jquery / html /php?
是否可以使用adobe reader强制所有浏览器(Chrome,FireFox,IE8 +)使用javascript / jquery / html / php打开pdf文件?
You could try this by using an iframe pointing to the pdf file. 您可以通过使用指向pdf文件的iframe来尝试此操作。 The browser will automatically open the pdf file using a pdf reader software on client machine.
浏览器将使用客户端计算机上的pdf阅读器软件自动打开pdf文件。 Like this:
像这样:
<iframe src="yourpdffile" style="width:100%;height:500px"></iframe>
you can't force something on the client for a security issue, but you can check with something like this . 你不能强迫客户端出现安全问题,但你可以检查一下这样的事情 。 My previous sentence follows by the experience that I have on browsers and coding but maybe I can say something wrong.
我之前的句子遵循我在浏览器和编码方面的经验,但也许我可以说错了。
You can control if there's Adobe Reader using javascript and a code that check if there is the Reader installed with a script like this (I've used these lines months ago and they work) 你可以控制,如果有ADOBE READER使用JavaScript和检查是否有与像脚本安装阅读器代码这个 (我这些线路个月前使用,他们的工作)
Try to use this plugin that maybe is for you pourpose (the first sentence link). 尝试使用这个插件,可能是你的pourpose(第一句话链接)。
You can also use google docs viewer
to achieve this functionality. 您还可以使用
google docs viewer
来实现此功能。
Just refer this link : https://docs.google.com/viewer 请参阅以下链接: https : //docs.google.com/viewer
You can get the iframe url and put it in your site. 您可以获取iframe网址并将其放入您的网站。
<iframe src="http://docs.google.com/viewer?url=http%3A%2F%2Fwww.yoursite.com%2Fpdf%2Ftest.pdf&embedded=true" width="600" height="780" style="border: none;"></iframe>
please note that the value
of the url
parameter in the src
is url encoded
. 请注意,
src
url
参数的value
是url encoded
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.