How to Embed PDF Files on Inner Pages of a Website
Question details
A website owner needs to publish and display PDF documents directly on a website's inner page without requiring visitors to download the file.

- Product
- Website HTML
- Device & OS
- not provided
- Scenario
- Publishing informational content, forms, or guides on a website for visitors to view natively in their web browsers.
- Observed behavior
- The user requires the correct HTML code and method to embed a PDF file directly into a webpage layout seamlessly.
Ensure your PDF file is optimized for the web to reduce loading times, and verify that you have access to your website's HTML source code or Content Management System (CMS) editor.
Embed the PDF Using an HTML Iframe
Using an iframe is the most widely supported and recommended method for embedding documents directly onto a webpage layout.
An HTML iframe element allows you to nest another webpage or document within your current page. It is natively supported by modern browsers for rendering PDF files directly.
Upload your PDF file to your website's media library or a trusted document-hosting service to obtain its direct file URL (e.g., /files/document.pdf).
Open the source code or HTML block editor of your website's inner page and paste the following code: <iframe src="/files/document.pdf" width="100%" height="800" title="PDF document"></iframe>
Modify the 'width' and 'height' attributes in the iframe code to perfectly fit your website's layout and responsive design requirements.
Add a standard HTML hyperlink directly below the iframe (e.g., <a href="/files/document.pdf">Download PDF</a>) so users on older browsers or mobile devices can easily download the file.

Embed the PDF Using the HTML Object Tag
An alternative embedding method that allows you to specify the MIME type of the document explicitly.
Optimize PDFs for the Web with WPS Office
Before embedding a PDF on your website, it's crucial to ensure the file size is optimized for fast loading and the content is perfectly formatted. WPS Office is a free, lightweight alternative to Microsoft Office that offers powerful PDF editing, creation, and compression tools.
- 1. Download WPS Office: Visit the official WPS website to download and install the lightweight suite.
- 2. Edit Your Document: Open your existing Word document or PDF to make final text, layout, or image adjustments.
- 3. Export and Compress: Save your file as a PDF and use the built-in compression tool to optimize it for web embedding.

Frequently Asked Questions
Why is my embedded PDF not displaying properly on mobile devices?
Many mobile web browsers (particularly on iOS) do not support native inline PDF rendering inside iframe or object tags. It is highly recommended to always provide a clear, direct download link alongside your embedded PDF so mobile visitors can access the document easily.
Can I embed a PDF from a third-party cloud service like Google Drive?
Yes, you can embed PDFs hosted on cloud services, provided the service allows public viewing and embedding. Instead of the raw file URL, you will need to generate a specific 'Embed Item' link from the sharing settings of that cloud service (like Google Drive or Dropbox) to use in your iframe.
How do I make the embedded PDF responsive to different screen sizes?
To ensure your PDF iframe scales to the screen size, set the width attribute to a percentage (e.g., width="100%") instead of a fixed pixel value. For the height, you may need to apply specific CSS styles or media queries to adjust the height proportionally for smaller screens.




