What is the recommended way to embed PDF in HTML?
What does Adobe say itself about it?
In my
Create a container to hold your PDF
<div id="example1"></div>
Tell PDFObject which PDF to embed, and where to embed it
<script src="/js/pdfobject.js"></script>
<script>PDFObject.embed("/pdf/sample-3pp.pdf", "#example1");</script>
You can optionally use CSS to specify visual styling, including dimensions, border, margins, etc.
<style>
.pdfobject-container { height: 500px;}
.pdfobject { border: 1px solid #666; }
</style>
source : https://pdfobject.com/
just use iFrame for PDF's.
I had specific needs in my React.js app, tried millions of solutions but ended up with an iFrame :) Good luck!
The URI for the iframe should look something like this:
/viewer.html?file=blob:19B579EA-5217-41C6-96E4-5D8DF5A5C70B
Now FF, Chrome, IE 11, and Edge all display the PDF in a viewer in the iframe passed via standard blob URI in the URL.
Using both <object>
and <embed>
will give you a wider breadth of browser compatibility.
<object data="http://yoursite.com/the.pdf" type="application/pdf" width="750px" height="750px">
<embed src="http://yoursite.com/the.pdf" type="application/pdf">
<p>This browser does not support PDFs. Please download the PDF to view it: <a href="http://yoursite.com/the.pdf">Download PDF</a>.</p>
</embed>
</object>
<object width="400" height="400" data="helloworld.pdf"></object>
Probably the best approach is to use the PDF.JS library. It's a pure HTML5/JavaScript renderer for PDF documents without any third-party plugins.
Online demo: http://mozilla.github.com/pdf.js/web/viewer.html
GitHub: https://github.com/mozilla/pdf.js