Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View a PDF file in HTML not to download it

Tags:

html

pdf

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.

like image 528
woninana Avatar asked Mar 02 '12 08:03

woninana


People also ask

How do I make a PDF non downloadable in HTML?

Making a PDF non-downloadable is as simple as adding #toolbar=0 to the URL.

Can you prevent a PDF from being downloaded?

Unless you host your own PDF viewer on your website such that the PDF file itself is not internally downloaded by whatever PDF reader the user has on their computer (i.e., your website displays a raster bitmap of the PDF content), there is absolutely no way to prevent the file from being downloaded and shared using ...

How do I make a PDF viewable online and not downloadable?

Find the file you want to share in OneDrive or SharePoint, and select the circle in the upper corner. Select Share at the top of the page. Select Anyone with the link can edit to open Link settings. Uncheck Allow editing, and then turn on Block download.

How do I stop Chrome from downloading PDF as HTML?

Chrome > Settings > Privacy & Security > Site Settings > Additional Content Settings > PDF Documents > UNCHECK Download PDF files instead of automatically opening them in Chrome.


2 Answers

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/)

like image 136
Aziz Avatar answered Oct 26 '22 06:10

Aziz


Mozilla created the PDF.js library. It displays pdf files in a web page without an external reader or plugin.

like image 29
VishnuMoorthy Avatar answered Oct 26 '22 08:10

VishnuMoorthy