0 votes
1 view
in Web Technology by (16.3k points)

What is the recommended way to embed PDF in HTML?

  • iFrame?
  • Object?
  • Embed?

What does Adobe say itself about it?

In my case, the PDF is generated on the fly, so it can't be uploaded to a third-party solution prior to flushing it.

1 Answer

0 votes
by (34.9k points)

Try using the code given below:

<embed src="http://example.com/the.pdf" width="500" height="375" 

 type="application/pdf">

The method is easy, quick and to the point and it doesn't require any third-party script:

UPDATE (1/2018):

The Chrome browser on Android no longer supports PDF embeds. You can just get around this by using the Google Drive PDF viewer like this:

<embed src="https://drive.google.com/viewerng/

viewer?embedded=true&url=http://example.com/the.pdf" width="500" height="375">

Or

You can just use the PDF.JS library. It's a pure HTML5/JavaScript renderer for PDF documents without any third-party plugins.

For an online demo, refer to this link: http://mozilla.github.com/pdf.js/web/viewer.html

GitHub: https://github.com/mozilla/pdf.js

...