Embed PDF in Website: HTML Code, Free Options, and Flipbook Alternatives
Copy working HTML code to embed a PDF in your website, compare free viewers like Google Drive and PDF.js, see why mobile browsers break plain embeds, and find out when a flipbook is the smarter choice for catalogs, reports and brochures.
You uploaded a PDF, pasted a link, and now visitors have to leave your page, wait for a download, and squint at a tiny preview. There is a better way. You can show the document right inside your page, and you can do it with a few lines of HTML or with a tool like Flipbooks AI that turns the same file into a page-turning reader. This article walks through both paths, with code you can copy, free options you can test today, and an honest look at where each one breaks.
💡 Quick answer: For a desktop-only audience, an <iframe> pointing at your PDF is the fastest fix. For anything that has to work on phones, use a viewer library or convert the PDF into a flipbook.
Why Embedding a PDF Gets Messy
PDF was built for print. It has fixed page sizes, embedded fonts and no idea what a 390-pixel-wide phone screen is. When you drop it into a web page, the browser has to decide how to render it, and every browser decides differently.
What Visitors Actually See
On desktop Chrome, Edge and Firefox, an embedded PDF usually appears in the browser's built-in viewer, complete with a toolbar, zoom and page counter. That toolbar is not yours, though. You cannot restyle it, you cannot hide the download button reliably, and you cannot track which pages people read.
Mobile Is the Real Problem
Open the same page on a phone and the story changes. iOS Safari often renders only the first page as a static image. Many Android browsers skip inline rendering and show a download prompt instead. Since most web traffic now comes from phones, a plain embed quietly fails for more than half of your visitors.
Here is a quick view of what to expect from the native browser approach:
Browser or device
Inline PDF display
Typical result
Chrome, Edge desktop
Yes
Full viewer with toolbar
Firefox desktop
Yes
Built-in PDF.js viewer
Safari desktop
Yes
Native viewer, limited styling
iOS Safari
Partial
First page only, hard to scroll
Android Chrome
Rarely
Download prompt or blank frame
The HTML Code That Works
HTML gives you three tags for embedding external documents. Each one has a place, and each one has limits.
The iframe Method
This is the most common approach because it is simple and widely supported:
The text after the # sign passes hints to the browser viewer. toolbar=0 hides the toolbar in Chrome and Edge, and page=3 opens the document on page three. These are hints, not guarantees, and Firefox and Safari ignore most of them.
⚠️ If your server sends the header X-Frame-Options: DENY or a restrictive Content-Security-Policy, the iframe will stay blank. Host the PDF on your own domain or adjust the headers.
The object Tag
The <object> tag lets you define a fallback, which is the one real advantage it has over iframe:
<object
data="/files/brochure.pdf"
type="application/pdf"
width="100%"
height="700">
<p>Your browser cannot display this PDF.
<a href="/files/brochure.pdf">Download it here</a>.</p>
</object>
When the browser cannot render the PDF, visitors see your fallback message and a download link instead of an empty rectangle. That small detail saves a lot of confused users.
It is free, fast to set up and works on mobile. The downsides are Google branding, a pop-out button that sends visitors to Drive, and no control over the design.
PDF.js from Mozilla
PDF.js is the open-source library that powers Firefox's viewer. You can host the viewer files yourself and point it at your document:
You get consistent rendering across browsers and a viewer you can restyle. The price is setup time and ongoing maintenance, since you host and update the files.
Free Embed APIs and Plugins
Adobe offers a free PDF Embed API that needs a client ID tied to your domain, and WordPress has several free plugins that add a PDF block to the editor. These work well for small sites, though free tiers often add limits or branding.
Option
Cost
Mobile support
Custom design
Setup effort
Native iframe
Free
Poor
None
Minutes
Google Drive preview
Free
Good
None
Minutes
PDF.js self-hosted
Free
Good
High
Hours
WordPress PDF plugin
Free or paid
Varies
Medium
Minutes
Flipbook converter
Free trial, paid plans
Excellent
High
Minutes
💡 Free is great for internal documents and quick tests. If the PDF is a sales tool, such as a catalog or a proposal, the free viewers leave money on the table.
Where Plain PDF Embeds Fall Short
Even a perfectly working embed has limits that matter for business content.
No analytics. You will not know whether anyone reached page four.
No branding. The viewer looks like a generic file reader, not your site.
Slow loading. A 40 MB catalog must download in full before page one appears.
No interactivity. Links, videos and audio inside the document are either dead or open in new tabs.
Easy to copy. Anyone can save the file and pass it around, and you have no control over access.
Picture a boutique owner with a 60-page lookbook. She embeds it with an iframe, tests it on her laptop, and it looks fine. Then a customer opens it on a phone, sees a blank box and leaves. That single failure costs more than the hour she would have spent picking a better method.
Flipbook Alternatives That Feel Better
A flipbook takes the same PDF and rebuilds it as a web-native reader. Pages load one at a time, the layout adapts to the screen, and visitors turn pages with a swipe or a click. Because it is a web page rather than a file, you can add the features a PDF never had.
Plain PDF vs Flipbook
Feature
Embedded PDF
Flipbook
Works on phones
Inconsistent
Yes, mobile-responsive
Page-turn effect
No
Yes
Custom colors and logo
No
Yes
Password protection
Server-side only
Built in
Reader analytics
No
Yes, on higher plans
Video and audio
No
Yes
Loads first page quickly
No
Yes
Offline download
Always possible
Optional, you decide
When a Flipbook Is the Better Pick
Catalogs and price lists where visitors browse before they buy
Magazines and newsletters where the reading experience is part of the product
Annual reports that need analytics on which sections people read
Lookbooks and portfolios where visual impact matters
Training manuals that need password protection
If you only need to show a one-page invoice, stay with an iframe. If the document is meant to impress or convert, a flipbook earns its place.
How to Embed a Flipbook in Minutes
Here is the full process using Flipbooks AI. It takes less time than setting up PDF.js.
Step 1: Create Your Account
Head to Flipbooks AI and sign up. You can try it free before choosing a plan, and every flipbook is free of watermarks, always.
Step 2: Upload and Convert the PDF
Drag your file into the PDF to Flipbook Converter. The platform processes each page and builds the reader automatically. Large files are fine, because pages load progressively rather than all at once.
✅ Best practice: Export your PDF at 150 DPI for screens. Higher resolutions make the file heavy without a visible gain.
Step 3: Customize the Look
Open the design panel and adjust:
Branding: upload your logo and choose brand colors
Background: pick a solid color, gradient or image behind the book
Page effects: set the flip animation and sound
Multimedia: drop in videos, audio clips and clickable links
Layout: switch between single-page and double-page views
Step 4: Copy the Embed Code
Open the share panel and choose the embed option. You get a snippet similar to this one (the URL below is a placeholder, so use the code from your own dashboard):
Paste it into any page builder, CMS or hand-coded site. The Embed Flipbook on Website tool explains the placement options for WordPress, Wix, Squarespace and Shopify. Prefer not to embed at all? Share the direct link instead, or add a password so only invited readers can open it.
Step 5: Turn On the Professional Plan Extras
The Professional plan adds the features that plain PDFs cannot match:
Analytics: see views, time on page and the pages that hold attention
Lead generation: ask readers for an email before they open the book
Offline downloads: let people save a copy when you choose to allow it
Unlimited flipbooks: available from the Standard plan and above
Real-World Use Cases
Different documents call for different tools. These examples show how teams put embeds to work.
A Restaurant Menu That Updates Itself
A restaurant owner keeps one flipbook on the website and swaps the PDF whenever the seasonal menu changes. The link and embed code stay the same, so no one touches the HTML. The Restaurant Menu Creator is built for exactly this.
A Product Catalog With Lead Capture
A furniture seller embeds a catalog on the category page and asks for an email at page three. Sales see who looked at which sofas. The Product Catalog Generator and Furniture Catalog Maker support this kind of setup.
Course Material for Students
A lecturer embeds weekly readings in the course site and protects them with a password. Students read on phones between classes without downloading anything. The Course Material Publisher fits this workflow well.
Skipping the mobile test. Always open the page on a real phone before you publish.
Linking to a huge file. Compress images inside the PDF first.
Forgetting alt text and titles. Screen readers need the title attribute on every iframe.
Using a fixed pixel width. Use width="100%" so the frame fits any screen.
Hosting on a domain that blocks framing. Check the X-Frame-Options header if the frame stays empty.
⚠️ Embedding a PDF you do not own can raise copyright questions. Confirm you have the right to publish the document before you put it on a public page.
Pick the Right Method
Use this table as a shortcut:
Your situation
Best method
Quick internal share, desktop users
iframe with a direct PDF link
Need a fallback message
object tag
Free and mobile friendly, no design needs
Google Drive preview
Developer who wants full control
Self-hosted PDF.js
Customer-facing, branded, tracked
Flipbook
Ready to Embed Your PDF?
For a quick test, paste the iframe snippet from this article into your page and see how it behaves. For anything visitors will judge you by, build a flipbook instead. Create your free account on Flipbooks AI, upload your PDF, and have an embed code ready before your coffee cools. Browse all flipbook tools and templates to find one that matches your document, or compare pricing plans to see which features fit your project.