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.