Embed PDF in HTML: Show a PDF Inside Your Web Page With iframe, object or PDF.js
One line of HTML puts a PDF on your page. Here's that line, the alternatives, and what to do on phones.

To embed a PDF in HTML, upload the file to your site and point an <iframe> at it: <iframe src="/files/brochure.pdf" width="100%" height="600"></iframe>. The visitor's browser then shows the PDF inside your page with its own built-in viewer.
Start with that one line. Phones and WordPress each need a small twist, and so does a PDF that refuses to show up.
Before You Embed: Get the PDF Ready
A smaller file loads faster for every visitor, so shrink the PDF with Compress PDF before you upload it. Our guide to optimized PDFs explains what each compression level changes.

We compressed a 12 page, 3.2 MB sample file with the Recommended level in November 2026 and got 388.3 KB. That's a big difference on a phone connection.
Two more checks. If the PDF needs a password to open, every visitor needs it too, so remove it with Unlock PDF if the document is meant to be public. And if only a few pages belong on the page, make a PDF of just those pages before you upload it.
Does a Big Embedded PDF Have to Download in Full?
Not with PDF.js, if your server cooperates. The PDF.js FAQ says it may fetch the parts it still needs with HTTP Range Requests, so a document can be rendered without fully loading it. That depends on the browser and on your server sending the range headers.
The same FAQ says to use web-optimized (linearized) output if you can. Compress PDF doesn't write that: in November 2026, qpdf --check-linearization reported our two compressed test files as not linearized.
Running the free qpdf command qpdf --linearize in.pdf out.pdf on one of them made it pass the same check, at 14.9 KB, up from 13.7 KB. The project's GitHub releases have macOS builds, and Debian packages it.
That FAQ only speaks for PDF.js. We found nothing official on how the viewers in Chrome, Edge and Safari load a file, so compress first whichever method you pick.
Method 1: Embed a PDF With an iframe
The <iframe> element loads another document into a box on your page. A PDF works like any other address:
1<iframe src="your-file.pdf" width="100%" height="600px"></iframe>Two attributes are worth adding. A title names the frame for screen reader users, and loading="lazy" waits to load the PDF until the visitor scrolls near it. MDN's reference for the iframe element documents both.
1<iframe src="/files/brochure.pdf" title="2026 product brochure (PDF)" width="100%" height="600" loading="lazy" style="border: 0"></iframe>You can also ask for a given page by adding #page=3 to the address, a parameter RFC 8118 defines for PDF files.
Method 2: The object Element With a Fallback Link
The <object> element does the same job, with one advantage: whatever you put inside it shows up when the browser can't display the PDF. That's where your download link goes.
1<object data="/files/brochure.pdf" type="application/pdf" width="100%" height="600">
2 <p>Your browser can't show this PDF here. <a href="/files/brochure.pdf">Download the brochure (PDF)</a>.</p>
3</object>Older guides also mention <embed>. It works, but it has no fallback content, so <object> or <iframe> with a link below it is the better pick.
Embedded PDFs on Phones
Always put a plain link to the PDF next to the embed, and test on a real phone. If the document must look the same everywhere, use PDF.js (method 3), which draws the pages itself.
Google's help says what that link does in Chrome on Android 12 and up: the PDF opens in Chrome, with no separate reader. In Incognito mode, the visitor gets a prompt to download it. That page covers links and says nothing about PDFs embedded in a page.
Method 3: PDF.js for the Same Viewer in Every Browser
PDF.js is Mozilla's open source PDF renderer, the one built into Firefox. It draws the pages with JavaScript, so it doesn't depend on the visitor's browser having a PDF viewer.

The simplest setup is the ready-made viewer from the PDF.js download. Upload its folder to your server and point an iframe at it, with your file in the address:
1<iframe src="/pdfjs/web/viewer.html?file=/files/brochure.pdf" title="Brochure (PDF)" width="100%" height="600"></iframe>The viewer is meant to run from a web server, since Mozilla notes its worker isn't enabled for file:// addresses. It's also the route if you want your own buttons or branding, since you can build a custom interface on the PDF.js library instead. Our PDF Viewer uses the same idea: the text of each page sits in an invisible layer over the drawn page, so visitors can search and copy it.
Method 4: Embed a PDF in WordPress
WordPress can do it without a plugin. In the block editor, add a File block and upload or pick the PDF.
In its settings, turn on Show inline embed and set the height in pixels. Show download button toggles the button.
For a viewer built on PDF.js, a plugin such as PDF Embedder adds one to your posts, and its page describes the viewer as responsive.

Adobe's PDF Embed API
Adobe's PDF Embed API is a JavaScript viewer that needs a client ID tied to your domain: on any other domain, Adobe says the preview is blocked. It can also send viewing analytics to Adobe Analytics or Google Analytics.

For a brochure or a menu, the methods above are enough, and no outside script runs on your page. If you want an API that changes PDFs rather than shows them, our post on what a PDF API does compares hosted services with open source tools.
Why Your Embedded PDF Doesn't Show
- The frame is blank or says the content is blocked: the server hosting the PDF sends an
X-Frame-OptionsorContent-Security-Policyheader that forbids framing. Host the file on your own domain, or change that header. - An
<embed>stays empty, or an<object>falls back to the text inside it, on your own site: your page's Content Security Policy may setobject-src 'none', which MDN recommends. In our test (headless Chrome on a Mac, one local server) that blocked both, and an iframe still loaded the PDF. A policy offrame-src 'none'blocked all three. - The PDF downloads instead of showing: the server sends
Content-Disposition: attachment. It needs to beinline, or left out. - Nothing shows on a phone: see the phone section above and add a download link.
- It loads slowly: compress the file, or split a long PDF and embed only the part you need.
Embedded PDFs and Search Engines
Google lists PDF as a file type it can index. If the content matters for search on your page, put a short HTML summary on the page next to the embed, or turn the PDF into a web page with PDF to HTML. Its output keeps each page's layout, so you'll still tidy the markup for an article.
Want to share a PDF without a page around it? Our guide on how to turn a PDF into a link covers that.
Frequently Asked Questions about Embed PDF in HTML
What's the HTML code to embed a PDF?
<iframe src="your-file.pdf" width="100%" height="600"></iframe>. Put the path or full address of your PDF in src and add a download link below it for phones.
Should I use iframe, embed or object for a PDF?
Use <iframe> for the simplest code, or <object> when you want fallback content inside it. Skip <embed>: it has no fallback.
What should I do when an embedded PDF doesn't show on a phone?
Add a plain link to the PDF, or use PDF.js, which draws the pages itself. Then test on a real phone.
Can I stop visitors from downloading an embedded PDF?
Not really. To display a PDF, the browser has to receive its data, so anyone can save it. Only put PDFs online that you're happy to share.
Can I embed a password-protected PDF?
Each visitor needs the password before anything shows. For a public page, remove the password first.


