Categories
HTML

How to Embed a PDF on an HTML Page?

Spread the love

Sometimes, we want to embed a PDF on an HTML page.

In this article, we’ll look at how to embed a PDF on an HTML page.

Embed a PDF on an HTML Page

To embed a PDF on an HTML page, we can use an iframe to embed the Google PDF widget into our page.

For instance, we can write:

<iframe src="https://docs.google.com/viewer?url=http://www.africau.edu/images/default/sample.pdf&embedded=true" style="position: absolute;width:100%; height: 100%;border: none;"></iframe>

We have a iframe with the src attribute set to:

https://docs.google.com/viewer?url=http://www.africau.edu/images/default/sample.pdf&embedded=true

http://www.africau.edu/images/default/sample.pdf is the PDF file URL.

We also set the styles to change the size of the PDF iframe.

Now, we should see the PDF file displayed.

Conclusion

To embed a PDF on an HTML page, we can use an iframe to embed the Google PDF widget into our page.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *