在HTML中查看PDF文件不要下载它 [英] View a PDF file in HTML not to download it

查看:111
本文介绍了在HTML中查看PDF文件不要下载它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的纯html文件,其中有很多PDF文件。我有这样的链接:

 < a href =pdffile.pdf> PDF 1 here< / a> 

当我点击链接时,PDF文件将被加载并在本地Reader程序中查看。我希望它在浏览器的另一个窗口中打开,然后在那里读取它,而不是手动将副本保存到我的计算机并打开它。 解决方案 div>

2018年更新



几乎所有现代浏览器都内置了PDF查看器。您可以直接链接到PDF文件,浏览器将查看它。如果您想在HTML页面(例如您的网站标题等)中查看它,也可以使用< iframe>

另一种方法,除了非常特殊的情况外,更复杂且不必要的是将PDF文件转换为HTML(如下面2012年答案中的#1所述) 。
$ b

原始答案(过时,从2012年开始)



在浏览器中查看PDF文件(无需下载)需要一个附加到客户端的浏览器。例如,谷歌浏览器有一个内置的PDF阅读器,可以直接打开文件,而IE和Firefox需要安装一个插件(Adobe Reader附带的插件)。



还有其他两种方法:将文件转换为HTML,图像或任何其他格式可以直接在浏览器中查看。这种转换可以使用服务器端(使用PHP,Python,ASP,任何语言编写)即时编译,或者您可以将所有文件预先转换为可读的文件。


  • 另一种最好的方法是使用基于Flash的PDF查看器(例如 http://flexpaper.devaldi.com/ )。这很简单,灵活,不需要编写服务器端代码。这种方法被许多文档共享网站(例如 http://www.scribd.com/ http://www.slideshare.net/ http://www.docstoc.com/



  • I have a very simple pure html file in which I have many PDF files. I have link it like this:

    <a href="pdffile.pdf"> PDF 1 here </a>
    

    When I click the link, the PDF file is downaloaded and viewed in the native Reader program. I want it to open in another window of the browser, and read it there, rather then saving a copy manually to my computer and opening it.

    解决方案

    2018 Update

    Almost all modern browsers have built-in PDF viewers. You can directly link to the PDF file and the browser will view it. You can Also use an <iframe> if you want to view it inside an HTML page (e.g. with your website headers, etc.).

    Another approach, but more complicated and not necessary except for very special circumstances, is to convert the PDF files to HTML (as described in #1 of the 2012 answer below).

    Original Answer (Outdated, from 2012)

    Viewing the PDF file in the browser (without download) requires an add-on to the client's browser. Google Chrome, for example, has a built-in PDF viewer and can open files directly, while IE and Firefox require that you install a plug-in (the one that comes with Adobe Reader).

    There are two other approaches:

    1. Convert the file to HTML, image, or any other format that can be directly viewed in the browser. This conversion can be on-the-fly using a server-side (written in PHP, Python, ASP, whatever language), or you can just pre-convert all files to a readable one.

    2. The other approach, which is the best, is to use a Flash-based PDF viewer (such as http://flexpaper.devaldi.com/). This is easy, flexible and doesn't require writing server-side code. This approach is used by many Document-sharing sites (e.g. http://www.scribd.com/, http://www.slideshare.net/, http://www.docstoc.com/)

    这篇关于在HTML中查看PDF文件不要下载它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆