How To Embed Pdf In Html

Adding a PDF file to your website can be a helpful way to share information with your visitors or include documentation for a product. In this blog post, we will cover different methods for embedding a PDF file in an HTML document.

1. Using the <embed> tag

The <embed> tag is one of the most straightforward ways to embed a PDF document in your HTML file. It allows you to specify the PDF file’s URL and dimensions. Here’s an example:

    <embed src="your-pdf-file.pdf" type="application/pdf" width="100%" height="600px">

Replace “your-pdf-file.pdf” with the URL or path to your PDF file. The “width” and “height” attributes determine the PDF viewer’s size; you can adjust these values according to your preference.

2. Using the <iframe> tag

The <iframe> tag is another simple way to embed a PDF in HTML. It creates a dedicated frame for the PDF viewer, which can be helpful for isolating the content. Here’s an example:

    <iframe src="your-pdf-file.pdf" width="100%" height="600px"></iframe>

As with the <embed> tag, replace “your-pdf-file.pdf” with the URL or path to your PDF file, and adjust the “width” and “height” attributes as needed.

3. Using the <object> tag

The <object> tag provides another method to embed a PDF file while offering some additional functionality. It allows you to display alternate content if the PDF viewer isn’t supported by the user’s browser. Here’s an example:

    <object data="your-pdf-file.pdf" type="application/pdf" width="100%" height="600px">
        <p>It appears you don't have a PDF plugin for this browser. You can <a href="your-pdf-file.pdf">download the PDF file</a> instead.</p>

Replace “your-pdf-file.pdf” with the URL or path to your PDF file, and adjust the “width” and “height” attributes as needed. The content within the <object> tag will be displayed if the browser doesn’t support PDF rendering.

Important Considerations

While embedding a PDF in HTML is relatively simple, it’s essential to keep in mind that not all browsers support PDF viewing. Using the <object> tag method can help provide an alternative for those users. Additionally, some mobile devices may not support embedded PDFs, so it’s a good idea to test your website on various devices and browsers to ensure compatibility.

Furthermore, embedding large PDF files may increase your website’s loading time, negatively impacting user experience. It’s a good idea to optimize your PDF files for web display by reducing their file size using compression tools or only embedding specific pages if possible.


Embedding a PDF in HTML is a simple process that can be achieved using the <embed>, <iframe>, or <object> tags. Each method has its benefits, and choosing the right one depends on your specific needs and compatibility requirements. Remember to optimize your PDF files and test your website on multiple devices and browsers for the best user experience.