Skip to content Skip to sidebar Skip to footer

How To Show Pdf Files To User's Browser,in The Case Of No Plugin Is Installed

how can we show pdf document in users browser.In the case the plugin is not installed. Is google api for pdf is usefull in this case?

Solution 1:

Google provides a tool to do this:

  • Option 1 - Generate your users a link:

    https://docs.google.com/viewer?url=my_domain.com/my_pdf.pdf

  • Option 2 - Embed into page so that users stay on your site:

    <iframe src="https://docs.google.com/viewer?url=my_domain.com/my_pdf.pdf&embedded=true">

Solution 2:

There's a variety of (horribly ugly) ways you could go about that. You could convert the PDFs (either on the fly, or before and store them) to a format that's usable (plaintext) which is then sent to the browser (either as plain text, or marked up a touch).

There's a variety of command line tools to do the conversion, such as pdftotext, along with some libraries. It's possible there's even PHP libraries with such functionality.

Though, you would need to use JavaScript on the client to detect the presence (well, lack there of!) of a PDF plugin, and then to load your converted document instead of a .pdf.

Solution 3:

There is a good start of viewing PDF using HTML5. They try to render PDF using native HTML5 element, so no plugin required. But sure it requires modern browsers.

I haven't tried it yet, but maybe you can take a look to pdf.js. This is the working demo.

Post a Comment for "How To Show Pdf Files To User's Browser,in The Case Of No Plugin Is Installed"