Thursday, September 10, 2009

Embed PDF and PowerPoint files on a web page with Google Document Viewer

Alex Chitu discovered a nifty trick to embed PDF files and PowerPoint slides on any webpage using Google Docs online Document Viewer. As you might be aware, there is an online Google Document Viewer that can open PDF, PPT files. The trick is to use an <IFRAME> to embed this Document Viewer on any page.

The code used here is:

<iframe src="http://docs.google.com/gview?url=http://users.powernet.co.uk/bearsoft/new_site/phys/qm-uncert.pdf&embedded=true" style="width:500 px; height:400px;" frameborder="0"></iframe>

Replace the URL of the file in the example above with the URL of the file you want to embed. Of course, that file must be uploaded somewhere online and directly accessible.

The <IFRAME> tag is pretty useful in embedding unsupported contents on any web page. I almost forgot I used this trick myself to embed a JavaScript example in one of my earlier post.

0 comments:

Post a Comment

Popular Posts