Other PDF Issues

How to Display a Cloud-Hosted PDF in a Website Iframe

Algirdas JasaitisAlgirdas Jasaitis Nov 5, 2026 868 views

Question details

The user wants to display a PDF file hosted on a cloud service within a website iframe.

How to Display a Cloud-Hosted PDF in a Website Iframe
Product
PDF
Device & OS
not provided
Scenario
Embedding a PDF document into a web page using an iframe so that visitors can view the document inline.
Observed behavior
Depending on the method used and browser settings, the PDF either displays directly within the iframe or is forced to download to the user's device.
Before you start

Ensure you have the embed code from your cloud storage provider and the necessary permissions to edit your website's HTML.

Solution 1Recommended

Use Embed Code from a Cloud Provider

Utilize the specific embedding features provided by cloud services to bypass standard browser download behaviors and reliably display PDFs.

Cloud storage platforms and document sharing services (like Google Drive or SlideShare) provide specialized iframe codes. These codes use their proprietary HTML5 viewers to render the PDF directly on the page, preventing the browser from triggering an automatic download.

1
Upload the PDF

Upload your PDF document to a cloud platform that supports embedding, such as SlideShare, Google Drive, or OneDrive.

2
Generate Embed Code

Locate the 'Share', 'Pop-out', or 'Embed' option in the platform's viewer interface.

3
Copy the Iframe Code

Copy the provided HTML iframe embed code generated by the service.

4
Insert into Website

Paste the embed code into your website's HTML editor precisely where you want the PDF to appear.

5
Test Across Browsers

Open the live web page in multiple browsers (Chrome, Edge, Firefox) to ensure the PDF viewer loads correctly and does not prompt a file download.

Use Embed Code from a Cloud Provider
Browser Limitations on Direct Links: If you use a direct URL to a PDF file inside an iframe instead of a cloud viewer embed code, the visitor's local browser settings will dictate whether the file opens inline or downloads automatically.
Optimize PDFs for the Web

Prepare and Compress PDFs with WPS Office

Before embedding a PDF on your website, ensure it loads quickly and displays beautifully by optimizing it with WPS Office. You can effortlessly compress, edit, and secure your PDFs before uploading them to your cloud host.

  1. 1. Open PDF in WPS Office: Launch WPS Office and open the PDF document you plan to embed on your website.
  2. 2. Edit and Watermark: Use the PDF tools tab to make necessary text edits or apply a watermark to protect your web-hosted content.
  3. 3. Compress the File: Click on 'Compress' in the toolbar to reduce the file size, which helps the iframe load faster for website visitors.
  4. 4. Save and Upload: Save the optimized PDF and upload it to your preferred cloud hosting service to generate your embed code.
Compress large PDF files to guarantee faster website loading timesHighly compatible with all standard Microsoft Office and PDF formatsAdd custom watermarks or edit text directly before web publishingLightweight, full-featured, and free alternative to Adobe Acrobat
QA img-9

Frequently Asked Questions

Why does my embedded PDF download instead of displaying in the iframe?

If you are using a direct link to the .pdf file as the iframe source, the behavior is controlled by the visitor's browser settings. If their browser is configured to download PDF files rather than opening them in a built-in viewer, it will force a download.

How can I force a PDF to display inline for all users?

You cannot override local browser settings using a direct PDF link. To guarantee inline display across all devices, you must use a cloud service embed code (like Google Drive) or a JavaScript PDF viewer library (like PDF.js) that renders the document using HTML5 rather than relying on the browser's native PDF capabilities.

Do I need to adjust the iframe dimensions for the PDF to look right?

Yes, you should set appropriate width and height attributes in your iframe tag (for example, width="100%" and height="600px") so that the embedded PDF or the third-party document viewer provides a readable experience on both desktop and mobile screens.