Using an iframe to "render" a PDF will not work on all browsers; it depends on how the browser handles PDF files. Some browsers (such as Firefox and Chrome) have a built-in PDF rendered which allows them to display the PDF inline where as some older browsers (perhaps older versions of IE attempt to download the file instead).

Instead, I recommend checking out PDFObject which is a Javascript library to embed PDFs in HTML files. It handles browser compatibility pretty well and will most likely work on IE8.

In your HTML, you could set up a div to display the PDFs:

<div id="pdfRenderer"></div>

Then, you can have Javascript code to embed a PDF in that div:

var pdf = new PDFObject({
  url: "https://something.com/HTC_One_XL_User_Guide.pdf",
  id: "pdfRendered",
  pdfOpenParams: {
    view: "FitH"
  }
}).embed("pdfRenderer");
Answer from Aamir on Stack Overflow
🌐
DevGenius
blog.devgenius.io › how-to-display-a-pdf-using-an-iframe-and-make-it-responsive-d3c3fcd3a460
How to Display a PDF Using an iframe and Make It Responsive | by Chad Murobayashi | Dev Genius
April 9, 2021 - When the screen size shrank, the size of the PDF inside the iframe would not change, causing it to side scroll like below. There were a few solutions I tried that I found in Stack Overflow, but nothing worked for me. Until finally, I came across a solution. It was so simple, I really couldn’t believe it. In this article, I will show you how to display a PDF using an iframe and make it responsive…
Discussions

html - IE8 embedded PDF iframe - Stack Overflow
I have used the tag to embed a pdf file. This works fine in Chrome, IE8+, Firefox etc, but for some reason, when some people ... More on stackoverflow.com
🌐 stackoverflow.com
Loading local PDF into IFrame using Javascript
However this issue is not specific to .Net and it is about javascript. My requirement is to give a preview of PDF document from local machine file system(c:\PDFS\abc.pdf) before uploading to the server. The webpage contains an IFrame and FILEUPLOAD control (to simplify: Input type=file) . More on experts-exchange.com
🌐 experts-exchange.com
April 18, 2008
javascript - Displaying and downloading a pdf in an iframe - Stack Overflow
I am using wix and in order to customize any html you need to use an embed object which creates a sandboxed iframe on the site. I have a decent grasp of how this works and posting messages to it but More on stackoverflow.com
🌐 stackoverflow.com
Opening a local pdf file in iframe with javascript - Stack Overflow
I am using the below code to open a pdf file but its not working- For a More on stackoverflow.com
🌐 stackoverflow.com
🌐
Docebo
community.docebo.com › learn & share › html & css › using pdf.js to display pdf's, control the interface, and retain links functionality
Using PDF.JS To Display PDF's, control the interface, and ...
December 20, 2023 - There are a few chats and ideas about making uploaded documents work differently, which I 100% agree should happen, but for those folks who have been able to have a seperate upload space and then use iframes to bring the document or link out to them, I wanted to writeup how I use PDF.JS to achieve this and not require programming knowledge.
Top answer
1 of 5
117

It's downloaded probably because there is not Adobe Reader plug-in installed. In this case, IE (it doesn't matter which version) doesn't know how to render it, and it'll simply download the file (Chrome, for example, has its own embedded PDF renderer).

If you want to try to detect PDF support you could:

  • !!navigator.mimeTypes["application/pdf"]?.enabledPlugin (now deprecated, possibly supported only in some browsers).
  • navigator.pdfViewerEnabled (live standard, it might change and it's not currently widely supported).

2021: nowadays the original answer is definitely outdated. Unless you need to support relatively old browsers then you should simply use <object> (eventually with a fallback) and leave it at that.


That said. <iframe> is not best way to display a PDF (do not forget compatibility with mobile browsers, for example Safari). Some browsers will always open that file inside an external application (or in another browser window). Best and most compatible way I found is a little bit tricky but works on all browsers I tried (even pretty outdated):

Keep your <iframe> but do not display a PDF inside it, it'll be filled with an HTML page that consists of an <object> tag. Create an HTML wrapping page for your PDF, it should look like this:

<html>
<body>
    <object data="your_url_to_pdf" type="application/pdf">
        <div>No online PDF viewer installed</div>
    </object>
</body>
</html>

Of course, you still need the appropriate plug-in installed in the browser. Also, look at this post if you need to support Safari on mobile devices.

Why an HTML page? So you can provide a fallback if PDF viewer isn't supported. Internal viewer, plain HTML error messages/options, and so on...

It's tricky to check PDF support so that you may provide an alternate viewer for your customers, take a look at PDF.JS project; it's pretty good but rendering quality - for desktop browsers - isn't as good as a native PDF renderer (I didn't see any difference in mobile browsers because of screen size, I suppose).

2 of 5
54

If the browser has a pdf plugin installed it executes the object, if not it uses Google's PDF Viewer to display it as plain HTML:

<object data="your_url_to_pdf" type="application/pdf">
    <iframe src="https://docs.google.com/viewer?url=your_url_to_pdf&embedded=true"></iframe>
</object>
🌐
W3Docs
w3docs.com › html
How to Embed PDF in HTML
Learn how to embed PDF documents in HTML using the a and iframes tags, and make PDF files not downloadable with W3Docs. Practice with examples
🌐
Nutrient
nutrient.io › blog › sdk › open pdf in your web app
Five easy ways to embed and display a PDF in HTML (no JavaScript needed)
June 3, 2025 - Use one of these native options: <object>, <iframe>, <embed>, or a combo of <object> + <iframe> for maximum fallback support. They’re quick to implement but come with tradeoffs like limited customization and uneven browser behavior.
🌐
PDF.js Express
pdfjs.express › blog › embed-pdf-files-or-pdf-viewer-in-website-v2
How to Embed a PDF Viewer in a Website in 3 Different Ways | Apryse
August 7, 2025 - Learn how to embed a PDF viewer in websites using HTML, open-source viewers like PDF.js, or a commercial SDK such as Apryse WebViewer.
Find elsewhere
🌐
Experts Exchange
experts-exchange.com › questions › 23335420 › Loading-local-PDF-into-IFrame-using-Javascript.html
Solved: Loading local PDF into IFrame using Javascript | Experts Exchange
April 18, 2008 - <!DOCTYPE html PUBLIC "-//W3C//DTD ... width="500"></iframe> <input type="button" value="Load" onclick="setIframeSRC('iFrame', 'file://I:\\Documents and Settings\\Name\\Desktop\\Test.pdf');" /> </body> </html>...
🌐
FlipHTML5
fliphtml5.com › home page › pdf tips & tools › pdf embedding › the best way to display pdf in iframe
The Best Way to Display PDF in iFrame - FlipHTML5
June 5, 2023 - Locate the embed code provided by FlipHTML5 and copy it. Then, navigate to the webpage where you want to display the flipbook and paste the embed code into the appropriate section of your HTML code.
🌐
Wisej.NET
wisej.com › support › question › print-pdf-file-by-iframe
Javascript Print Pdf file by IFrame – Wisej.NET
May 15, 2020 - var objFra = document.createElement('iframe'); // Create an IFrame. objFra.style.visibility = "hidden"; // Hide the frame. objFra.src = "ReadMe_001.pdf"; // Set source not done .pdf. objFra.onload = function(){ objFra.contentWindow.focus(); // Set focus. objFra.contentWindow.print(); // Print it }; document.body.appendChild(objFra); // Add the frame to the web page. ... Please login first to submit. This site uses cookies.
🌐
Stack Overflow
stackoverflow.com › questions › 66609249 › displaying-and-downloading-a-pdf-in-an-iframe
javascript - Displaying and downloading a pdf in an iframe - Stack Overflow
<html> <head> <script src="https://github.com/foliojs/pdfkit/releases/download/v0.11.0/pdfkit.standalone.js"></script> <script src="https://github.com/devongovett/blob-stream/releases/download/v0.1.3/blob-stream.js"></script> <script type="text/javascript"> window.onmessage = (event) => { if (event.data) { // create a document and pipe to a blob var doc = new PDFDocument(); var stream = doc.pipe(blobStream()); doc.font('Helvetica'); doc.fontSize(20); doc.text('Some Text',200,20); // end and display the document in the iframe to the right doc.end(); stream.on('finish', function() { const blob =
🌐
OpenReplay
blog.openreplay.com › step-by-step--embedding-pdfs-in-html-pages
Step by step: embedding PDFs in HTML pages
Here is the result of our embedded PDF file: By default, the <iframe> tag has a border around it, which we can remove or style further with the CSS border property. We can also use CSS to style the content within the <iframe> differently from the rest of the document. For interactions with the main HTML document and other <iframe> tags, we use JavaScript.
🌐
Nutrient
nutrient.io › blog › sdk › how to embed a pdf viewer in your website
How to embed a PDF viewer in a website: Six methods (2026 guide)
March 23, 2026 - The most reliable fix is to use a JavaScript-based PDF viewer, which renders the PDF using its own engine rather than relying on the browser’s built-in PDF handler. Why is my iframe showing a blank page instead of the PDF?
🌐
Pdfobject
pdfobject.com
PDFObject
PDF embedding made easy. An open-source JavaScript utility for embedding PDF files into HTML documents.
🌐
SitePoint
sitepoint.com › blog › javascript › load pdf into iframe and call print
Load PDF into iframe and call print — SitePoint
February 12, 2024 - Yes, you can load a PDF into an iFrame and print it using jQuery. Here is an example: $("#myIframe").attr("src", "path/to/your/pdf.pdf"); $("#myIframe").get(0).contentWindow.print(); In this code, ‘myIframe’ is the ID of your iFrame, and “path/to/your/pdf.pdf” is the path to your PDF file.
🌐
Stack Overflow
stackoverflow.com › questions › 78847868 › using-iframe-to-show-pdf-and-open-at-a-particular-page-by-the-given-offset-and-a
javascript - Using iframe to show pdf and open at a particular page by the given offset and also highlight any given text - Stack Overflow
But I can not show you that, since newer Firefox corrupts my device, thus I have deleted all versions for now! see How to enable PDF search option using embed or Iframe in HTML · For the majority of browsers which are either Mozilla PDF.js or Chromium based like Edge, you need a command to just fit page 13 (without any highlighting). https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf#page=13&view=fitH · However the newest Edge with Acrobat (the upsell version) will not even go to page 13! What you would need is a Binary plugin that uses search but then they will not usually use Java or JavaScript and ignore external commands except from the desktop client.
🌐
PKP Community
forum.pkp.sfu.ca › software support
[OJS 3.1.1.4] How to embed a pdf file in an iFrame - Software Support - PKP Community Forum
May 19, 2020 - Hi, How do you embed a pdf file in an iFrame? Apparently you can’t use the same method you use when you insert images in your html file. If we use the same method it will start downloading the pdf when opening the artic…