StaticVariable
StaticVariable

Reputation: 5283

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?

Upvotes: 4

Views: 2624

Answers (3)

Muhammad Abrar
Muhammad Abrar

Reputation: 2322

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.

Upvotes: 0

Thomas
Thomas

Reputation: 11888

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">

Upvotes: 4

Kitsune
Kitsune

Reputation: 9341

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.

Upvotes: 0

Related Questions