How to embed a PDF in a web page (and what you can't see once you have)
The short way to embed a PDF in a web page is an iframe or an object tag pointing at the file's URL. The browser's built-in viewer does the rest. Two lines of HTML and the document appears on your page, scrollable, no plugin.
That's the easy half. The half people skip is what happens after: phones that show a download button instead of your document, a host that refuses to be framed, and a page that tells you nothing about whether anyone read past the first screen. I've embedded PDFs on landing pages for years, and the embedding was never the hard part.
The iframe is the quickest way to embed a PDF
This is the version I'd start with:
<iframe
src="/files/pricing-guide.pdf"
title="Pricing guide (PDF)"
width="100%"
height="800"
loading="lazy"></iframe>
Three details matter more than they look. Give it a title, because without one a screen reader user has to go inside the frame to find out what it contains, which MDN's iframe reference points out is especially confusing when a page has several embeds. Set an explicit height, because a PDF frame has no natural height and will otherwise collapse to a small default box. And loading="lazy" stops a heavy PDF being fetched until the reader is near it, which helps if the embed sits below the fold.
Then put a plain link to the file next to it. Always. That's not a nicety, it's your fallback, and I'll come back to why.
The object tag gives you a fallback inside the embed
object does the same job with one real advantage. Whatever you put between the tags is shown when the file can't be displayed:
<object
data="/files/pricing-guide.pdf"
type="application/pdf"
width="100%"
height="800">
<p>Your browser can't show this PDF.
<a href="/files/pricing-guide.pdf">Download it instead</a>.</p>
</object>
MDN's own advice is to use that fallback for a link to the PDF, and also to keep a link outside the element, so the file stays reachable if the viewer loads but fails to render. I follow that. In practice the choice is simple: object if you want a built-in fallback, iframe if you want the simplest thing that works. Neither is better at displaying the PDF, because in both cases the browser's own viewer is doing the displaying.
Embedding a PDF breaks in three predictable places
Here's where it goes wrong, roughly in the order I've been bitten.
Phones
Mobile browsers handle inline PDFs differently from desktop ones, and some don't give you a scrollable document at all. You may get a first-page preview or a prompt to download. I can't give you a reliable per-browser list, and I'd distrust anyone who claims one, so the honest advice is to test on the actual phones your readers use. A lot of PDFs get opened on a phone first, so this isn't an edge case.
Hosts that refuse to be framed
A server can tell browsers not to display its content inside someone else's page, using the X-Frame-Options header or the frame-ancestors directive in a Content Security Policy. What matters is the policy, not just whether a header is there. X-Frame-Options: SAMEORIGIN allows framing only by pages on the same origin, DENY blocks everyone including you, and frame-ancestors can list exactly which sites may embed the file. If the policy doesn't allow your page, your iframe shows an empty box or an error. The fix is to host the file somewhere whose policy permits your page, usually your own domain, and check that your own server isn't sending DENY or frame-ancestors 'none'. PDF hosting covers where a file can live and what that costs.
Big files and slow pages
An embedded PDF is still a PDF. A 40 MB file with full-resolution photographs will make your page feel slow before anyone has scrolled. Compress it first, or don't embed it and link to it.
A custom viewer is more work than it sounds
If the built-in viewer isn't good enough, you can render pages yourself with a JavaScript library such as Mozilla's PDF.js. You get control over the look, the toolbar and the layout, and you can build page controls that match your site.
I'd think hard before doing it. You're now maintaining a viewer: updates, accessibility, mobile quirks, large-file performance. For a documentation site where the PDF is the product, that can be worth it. For a one-off proposal or a lead magnet, it's a lot of engineering to put a document in a box.
An embedded PDF viewer can't tell you if anyone read it
This is the part I care about, and it's why I wrote this post at all.
When the browser's built-in viewer shows your PDF inside a frame, your page can't see what's happening inside it. The frame is a window onto another document. Your analytics can tell you the page loaded. They can't tell you which pages of the PDF someone scrolled to, how long they stayed on page six, or whether they went back to the pricing. You embedded the thing and lost sight of it.
Plenty of people assume the page view is the engagement signal. It isn't. A visit to the page with the embed on it is a visit, not a read. That's the same trap as an email open: it tells you the door was opened, not that anyone went in the room. I wrote about the gap in can you tell if someone opened a PDF, and an embedded viewer is the same problem on a web page.
Embedding is also the wrong shape for a document you're sending to one person. A PDF in a frame on a page is a static object with nobody guiding the reader through it. If it's a proposal or a report, the thing you're missing is the explanation, not the viewer.
When something other than an embed is the better call
If the PDF is public and the page view is all you need, embed it and move on. A brochure, a menu, a spec sheet. Use the iframe, keep the download link beside it, done.
If the point is that someone understands the document and you want to know how they engaged with it, the embed is the weak option. Tools built for this show you page-level behaviour, which is what PDF tracking software means in practice. For plain sending, sharing a PDF as a link skips the embed entirely, and PDF sharing sites compares the main options.
That's the problem I built LiveDocument for. You attach a recorded video walkthrough to a PDF or an image and share both as one link, with clickable highlights that jump the video to the right section and page-level engagement analytics behind it. It's a shared link, not an embed you paste into your own site, so if the requirement is the document living inside your own page layout, this isn't the tool. The access controls are link expiry and revocation, nothing fancier. If you want to see how the walkthrough side works, there's a demo, and the pricing page has the current plans.
One more thing on video. If your instinct was to put a video inside the PDF before embedding it, that mostly only plays in Adobe's own software and often shows a dead frame in a browser viewer. How to get a video into a PDF file goes through why.
What I'd actually do
For a public document, an iframe with a title, an explicit height, lazy loading and a visible download link beneath it. I'd host the file on my own domain so framing isn't blocked, and I'd open the page on my phone before calling it finished.
For a document where understanding matters, I'd stop thinking about embedding. I spent a long time in growth roles pasting PDFs into pages and then guessing whether anyone read them. The embed looked tidy. It just didn't answer the question I had.
FAQ
What's the simplest way to embed a PDF in a web page?
An iframe whose src points at the PDF's URL, with a title, a set height and a normal link to the file nearby. The browser's built-in viewer renders it, so there's nothing to install on your side.
Should I use iframe or object to embed a PDF?
Both hand the job to the browser's viewer. object lets you put fallback content, such as a download link, between the tags for when the PDF can't be shown. iframe is simpler. Whichever you pick, keep a separate link to the file outside the embed.
Why is my embedded PDF blank or showing an error?
The most common cause is the server hosting the PDF refusing to be framed, through X-Frame-Options or a CSP frame-ancestors rule. Host the file on your own domain, or somewhere that allows embedding, and check the URL actually returns the PDF.
Can I track who reads a PDF embedded on my website?
Not page by page. Your analytics can record that the page loaded, but the built-in viewer inside an iframe isn't visible to your page, so you won't see which PDF pages were read. For that you need a tool that tracks the document itself.
Send it as a link when someone has to understand it
Embeds are fine for public files. For the documents that need to land, I'd rather put a face and a voice on them. That's what livedocument.com is for.
About the Author
Cameron JamesCameron is the founder of LiveDocument. He writes about sharing documents, PDFs, decks and contracts, and why pairing a video walkthrough with a document beats sending it cold.