PDF view in browser

Asked

Viewed 3,447 times

1

I am searching a way to view PDF file in the browser and print everything through the web (This action will be done by the user). Someone knows a tool that works with it. I’m using PHP and Mysql in my project. My intention is that you look like the PDF viewer of Microsoft Skydrive. But not with all the features. Viewing and printing only!

  • I don’t understand what your question is? A tool to print pdf for what? This has to be automatic? The user who will request the print?

  • I will re-edit to be clearer @Felipeavelar

  • Maybe that one question help you with a starting point.

  • Vlw really was what I look for @lost

  • Which library you are using to generate the PDF ?

2 answers

4


Usually browsers are able to render PDF, so the simplest way is to forward the user directly to the pdf with a simple link or still using a <iframe>. If the browser cannot render, the file will be downloaded.

An alternative is to use the PDF.js:

pdf.js is an HTML5-based technology experiment that aims to build a faithful and efficient Portable Document Format (PDF) renderer without the help of native code.

You can see an example of it working here: demo. Note the print button in the upper right corner.

On Github: Source Code.

  • I already had a very nice look... I think that’s the one I’ll use! vlw

  • The answer is fundamentally correct, but I would like to mention a fact - no browser is able to render PDF content. What happens is that they can internally invoke a MIME Type-specific Handler application/pdf, but you need it to be previously installed. If MIME Type is not informed by the server the browser will offer the download window.

  • 1

    @Onosendai Firefox does not read native Pdfs? inclusive, if I’m not mistaken, it’s pdf.js that does this.

  • @Onosendai If so I can argue that no browser is capable of rendering html. They depend on some internal Handler for the text/html... And everyone has. In the case of pdf, several have by default rendering means like firefox and Chrome (but not Chromium).

  • @athosbr99 Actually Firefox has a built-in PDF viewer, but mechanically the result is the same: Via HTTP the server announces the file type, and the module browser Firefox invokes the module PDF Viewer. Still you can indicate in the FF that you want to use an external Viewer.

  • @Guilhermebernal would be a valid argument if it were possible to invoke directly, for example, the Chrome rendering engine within IE. By definition (at least for Windows) html is a class directly associated with an Handler: You can check this in the registration key HKLM\SOFTWARE\Classes\.html\OpenWithProgids, where installed browsers are listed as such.

Show 1 more comment

1

You can use the Google Docs viewer, which allows you to reference online documents (e.g. PDF, DOC, etc.), and then use one of the options given by Viewer:

  • URL: url of the view page

  • Link <a href='...'> lets you connect to a view page

  • Iframe <iframe src='...'></iframe> allows you to add the pdf Embedded to any page

It works on all the browsers I’ve tested... even in IE7 it works.

To place the document inside your site, you can use the iframe option, and add it to any page.

Example of iframe generated by Viewer:

<iframe src="http://docs.google.com/viewer?url=http%3A%2F%2Fdownload.inep.gov.br%2Feducacao_superior%2Fenade%2Fmanuais%2Fmanual_enade_2013.pdf&embedded=true" width="600" height="780" style="border: none;"></iframe>

Obviously, you can generate this tag in your code, if necessary.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.