Embed PDF in HTML
Get ready-to-paste code that shows a PDF on your web page, from your own site, Google Drive or Dropbox. Pick a viewer, a download button or a link card, test it here, then copy it.
Free · no sign-up · nothing uploaded
The PDF must already be online where your visitors can reach it: your own site, Google Drive or Dropbox. This tool doesn’t upload or host files.
How to embed a PDF in a website
- Put the PDF online. Upload it to your website’s media library, or share it from Google Drive or Dropbox so anyone with the link can open it.
- Paste its link above and give it a short title, such as “Our menu”. Screen readers read the title out.
- Pick how it should appear: a viewer on the page (iFrame), a download button, or a card that opens the PDF in a new tab.
- Click Generate HTML, then Test it here to check the PDF really shows.
- Copy the code and paste it where you want it in your page’s HTML, or in your site builder’s HTML or code block.
The code for a viewer with a link underneath looks like this:
<iframe src="https://example.com/menu.pdf" title="Our menu" style="width: 100%; height: 600px; border: 0;" loading="lazy"></iframe> <p><a href="https://example.com/menu.pdf" target="_blank" rel="noopener">Open our menu (PDF)</a></p>
A width of 100% fills the space the code sits in, so it shrinks to fit on a phone. The height is fixed, because a PDF viewer has no natural height of its own; 600 to 800 pixels shows most of a page.
Embedding a PDF from Google Drive or Dropbox
Google Drive: share the file with Anyone with the link, copy the link and paste it above. A normal share link ends in /view, which Drive won’t let other sites show, so the tool changes it to the /preview link Drive allows. Drive draws the pages itself, so this viewer also works on phones. Drive’s own Embed item option (in the ⋮ menu when the file is open in a new window) gives the same link.
Dropbox: create a share link and paste it. It ends in dl=0, which opens Dropbox’s page; the tool changes it to raw=1 so the PDF itself is served. Use Test it here to make sure it shows.
Google Docs, Sheets and Slides: paste the share link in the same way. It is changed to the /preview link, and the download button saves the file as a PDF.
OneDrive: a share link opens OneDrive’s page and usually won’t show on other sites. Right-click the file in OneDrive, choose Embed, and paste the link from the code it gives you.
Whichever you use, anyone who can see your page can open the file, so don’t embed anything private this way.
Adding it to WordPress, Wix or Squarespace
- WordPress: the easiest way needs no code. Add a File block, upload the PDF and switch on Show inline embed. To use the code instead, add a Custom HTML block and paste it. On WordPress.com, iframe code only works on plans that allow custom code.
- Wix: click Add Elements (+), then Embed Code and Embed HTML. Choose Code, paste it in, and drag the box to the size you want.
- Squarespace: add a Code block where the PDF should go and paste the code. Code blocks are only available on plans that include custom code.
Choose WordPress, Wix, Squarespace in the tool to get the code with these steps underneath it.
Why the PDF doesn’t show
- It’s a phone. Chrome on Android usually can’t show a PDF inside a page, and iPhones often show only the first page. That is what the Open the PDF link underneath is for. A Google Drive viewer works on phones too.
- The host refuses. Many sites, including Google Drive’s normal share page, tell browsers not to show their pages inside other sites. The box stays blank or says it “refused to connect”. Host the PDF yourself, or use a Drive
/previewlink. - The link starts with http://. A page served over https:// won’t load http:// content in a frame. Use the https:// address.
- The file is private. A link that only works while you are signed in won’t work for visitors. Open it in a private window to check.
- The builder strips the code. Some site plans remove iframes from pasted HTML. Use the builder’s own PDF or file block, or a link card.
Frequently asked questions
How do I hide the toolbar or the download button?
Tick Hide the viewer toolbar. Chrome and Edge then show the PDF without their toolbar; other browsers may ignore it. It can’t stop people saving the file, because the PDF’s link is in your page’s code.
Can the PDF open at a certain page?
Yes. Type the page number in Open at page. The tool adds #page= to the link, which Chrome, Edge and Firefox follow. It doesn’t work with Google Drive’s viewer.
Can I embed a PDF that’s on my computer?
Not directly, because visitors can’t reach files on your computer. Upload it to your website, Google Drive or Dropbox first, then paste that link here.
Is anything uploaded?
No. The tool only builds code from the link you paste; it never sees the PDF itself. The test viewer loads the PDF straight from where it’s hosted, just as your visitors’ browsers will.
Sources
- MDN: <iframe>: how an iframe loads another page or file, and the title attribute for screen readers.
- MDN: <object>: showing a resource with fallback content inside the tag.
- MDN: <embed>: an embedded resource with no fallback content.
- WordPress: File block: uploading a PDF and showing it inline without code.
- Squarespace Help: Code blocks: adding custom HTML to a page.
Related Tools
Convert BMP images to PDF.
Convert WEBP images to PDF.
Fix crooked scanned pages.
Trim margins or whitespace from pages.
Apply legal Bates numbering.
Remove comments and markups.