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
🌐
Raymond Camden
raymondcamden.com › 2024 › 12 › 17 › adding-pdfs-to-your-webpage-without-javascript
Adding PDFs to Your Webpage without JavaScript
Also note as I said above, the width and height I picked isn't necessarily the best, and the two PDFs used here don't have the same form factor. I'd expect usually you would want to think about that for your list of PDFs. Pretty simple, right? If you want to grab a copy of the code I used above, you can find it at my repo here: https://github.com/cfjedimaster/webdemos/tree/master/iframe_pdf
🌐
egghead.io
egghead.io › tips › embed-pdfs-in-html-with-embed-iframe-and-object-tags
Embed PDFs in HTML with embed, iframe, and object tags
Now embed is part of the HTML5 ... browser doesn't support PDF embedding, which still happens frequently · 00:36 with browsers and mobile devices, the end user will see nothing. So there's two ways around that. The first is by using an iframe....
Discussions

Display pdf in Web Page using iframe, embed, or object?
I've never done it, but I'd think creating an iframe and setting the src to your pdf, as you describe, would do it. This isn't a server thing, though, all you need to make sure is the content type of the link is pdf, then the browser takes it from there. More on reddit.com
🌐 r/learnprogramming
5
1
September 26, 2018
[OJS 3.1.1.4] How to embed a pdf file in an iFrame
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 articlle and not show it in the article. We’re running OJS 3.1.1.4 Best Niels Erik More on forum.pkp.sfu.ca
🌐 forum.pkp.sfu.ca
9
0
May 19, 2020
Embedding a SharePoint PDF document in an iframe shows a blurry document at the same zoom level compared to opening the document directly in SharePoint
We have an application where we use SharePoint APIs to get documents and its information. Once we have the document IDs, we then allow to launch the SharePoint documents within an iframe in the application. However, we noted that the SharePoint PDFs… More on learn.microsoft.com
🌐 learn.microsoft.com
2
0
html - IE8 embedded PDF iframe - Stack Overflow
🌐 stackoverflow.com
🌐
Pdfobject
pdfobject.com › static
How to embed a PDF without using JavaScript | PDFObject
Please download the PDF to view it: <a href="/pdf/sample-3pp.pdf">Download PDF</a>. </object>Example fallback content: This browser does not support PDFs. Please download the PDF to view it: Download PDF. Using an <object> with an <iframe> provides extra insurance if <object> is not supported.
🌐
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 - Combining <object> and <iframe> tags leverages the strengths of both elements. Here’s an example: ... This option is best for ensuring maximum compatibility. It combines the fallback capabilities of <object> with the customization options of <iframe>. The simplest approach is linking to the PDF directly using an <a> tag:
🌐
Reddit
reddit.com › r/learnprogramming › display pdf in web page using iframe, embed, or object?
r/learnprogramming on Reddit: Display pdf in Web Page using iframe, embed, or object?
September 26, 2018 -

I'm trying to display a PDF in my web page but not have it open a new page. I've been looking at embed, iframe, and object tags and have seen their pros and cons and I'm more or less pushing for iframe. I select the file from a treeview that gets the files from a REST API and I want to add the selected file to the src of the iframe but don't know exactly how to do it. I was able to make it so the file opens to its own page but not sure about embedding it. Any advice?

Here's my code to display the file in its own page. filePath is the full path for the file and selectFile is just the file name itself.

 Dim user As WebClient = New WebClient()
        Dim buffer As Byte() = user.DownloadData(filePath)
        If Not buffer Is Nothing Then
            Response.AddHeader("content-length", buffer.Length.ToString())
            Response.AddHeader("Content-Disposition", "inline; filename=" + selectFile)
            Response.ContentType = "application/pdf"
            Response.BinaryWrite(buffer)
        End If

Find elsewhere
🌐
DEV Community
dev.to › asifroyal › displaying-pdf-files-in-an-iframe-a-simple-solution-2anj
Displaying PDF Files in an Iframe: A Simple Solution - DEV Community
December 21, 2022 - Are you looking for a way to embed a PDF file on your website without relying on external services or plugins? If so, then you're in luck! In this tutorial, we'll show you how to use PHP and cURL to download the content of a PDF file from a URL and display it in an iframe.
🌐
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…
🌐
OpenReplay
blog.openreplay.com › step-by-step--embedding-pdfs-in-html-pages
Step by step: embedding PDFs in HTML pages
Embedding PDF files from untrusted sources can expose the website to security vulnerabilities. The <object> tag is like the <iframe>, as we use both tags to embed external content in an HTML document. We use the <object> tag to embed a wide range of external content like multimedia, Java Applets, etc. Example of using the <object> tag to embed a PDF file:
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 700485 › embedding-a-sharepoint-pdf-document-in-an-iframe-s
Embedding a SharePoint PDF document in an iframe shows a blurry document at the same zoom level compared to opening the document directly in SharePoint - Microsoft Q&A
Image of the rendering of PDF in iframe: (URL template we use for embedding: https://<sharepoint_site>/:b:/r/sites/FinancialDocs/_layouts/15/WopiFrame2.aspx?sourcedoc={<document_id>}&action=interactivepreview).
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>
🌐
SitePoint
sitepoint.com › blog › javascript › load pdf into iframe and call print
Load PDF into iframe and call print — SitePoint
February 12, 2024 - You can use the ‘src’ attribute of the iFrame to set the source to the PDF file. Here is a simple example: var iframe = document.getElementById('myIframe'); iframe.src = "path/to/your/pdf.pdf"; In this code, ‘myIframe’ is the ID of your iFrame, and “path/to/your/pdf.pdf” is the ...
🌐
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 - Discover five quick methods to embed or display PDF files directly in your HTML pages using iframe, embed, and object tags. Includes pros, cons, and best practice tips for responsive, accessible PDFs.
🌐
Apryse
apryse.com › 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 - <head> <title>Title of the ...df">download pdf</a> </object> </body> <iframe src="document.pdf" width="100%" height="100%" style="border:none" title="Embedded PDF Viewer" ></iframe>...
🌐
New Mexico State University
learncascade.nmsu.edu › tutorials › creating-a-pdf-embed.html
Creating a PDF Embed | New Mexico State University - BE BOLD. Shape the Future.
**To add a PDF using iframe tags on your page. Use the the Source code button when editing. Insert the code from below. Then, manually insert the path of your PDF file (the URL), after the part that reads: src= **For example: An inside path: src=/_folder/MySpecialDocument.pdf ·