Embed a PDF in an iframe

This is definitely the easiest way to display a PDF file on your website: The PDF is loaded through Google docs and then displayed in an iframe, on your own site.
To use this shortcode, first paste the code below into your functions.php file:

 
function cwc_viewpdf($attr, $url) {
    return '<iframe src="http://docs.google.com/viewer?url=' . $url . '&embedded=true" style="width:' .$attr['width']. '; height:' .$attr['height']. ';" frameborder="0">Your browser should support iFrame to view this PDF document</iframe>';
}
add_shortcode('embedpdf', 'cwc_viewpdf');

Then, use the following syntax to display a PDF. As you can see, it is possible to define width and height, which means that this shortcode will fit great on your blog, nevermind its layout.

[embedpdf width=”600px” height=”500px”]http://infolab.stanford.edu/pub/papers/google.pdf[/embedpdf]