简体   繁体   English

如何在浏览器中显示pdf并允许Adobe Reader下载/打开它?

[英]How to show pdf in browser and allow to download/open it by adobe reader?

I need to make possible to preview the pdf file in the browser window for example in and to make some button which allow to open it in Adobe Reader program for edit purpose. 我需要使在浏览器窗口中预览pdf文件成为可能,例如,要使它能够在Adobe Reader程序中打开以进行编辑。

The problem I encountered is that if browser know how to treat PDF's files it will not allow me to download it, and always open it in a new tab. 我遇到的问题是,如果浏览器知道如何处理PDF的文件,它将不允许我下载它,并始终在新选项卡中将其打开。 and if I config browser not to open PDF file inside browser it allow me to download file but it will not show me the PDF inside 如果我配置浏览器不打开浏览器内部的PDF文件,它将允许我下载文件,但不会向我显示PDF

any body have some Idea how can i combine this two requirements in one html page? 任何机构都有一些想法,我怎样才能在一个HTML页面中结合这两个要求?

i need the solution for Internet Explorer 11 我需要Internet Explorer 11的解决方案

It's possible but there's a bit of plumbing involved. 可能,但是涉及一些管道。 Basically, you don't link to the PDF directly, you link to an HTML page that uses an object element to display the PDF in most of the window. 基本上,您不会直接链接到PDF,而是链接到使用对象元素在大多数窗口中显示PDF的HTML页面。 You can then have a header that holds a button that calls a JavaScript to fetch the PDF and save it locally. 然后,您可以拥有一个标头,其中包含一个按钮,该按钮调用JavaScript来获取PDF并将其保存在本地。 My example uses download2.js for that part. 我的示例在那部分使用download2.js。 It even works in IE 11 though I don't think it will work in anything lower than IE 8. 它甚至可以在IE 11中运行,尽管我认为它不能在低于IE 8的环境中运行。

See the example at the URL below. 请参见下面的网址中的示例。 http://practicalpdf.com/solutions/practicalpdf/preview-with-button/wrapper-with-button.html http://practicalpdf.com/solutions/practicalpdf/preview-with-button/wrapper-with-button.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM