Skip to content

Instantly share code, notes, and snippets.

@jimboobrien
Forked from wpscholar/load-pdf.php
Created September 20, 2017 23:32
Show Gist options
  • Save jimboobrien/ea8b1567177a3da0774ddefe96268e95 to your computer and use it in GitHub Desktop.
Save jimboobrien/ea8b1567177a3da0774ddefe96268e95 to your computer and use it in GitHub Desktop.
WordPress shortcode loads a PDF file on your site in an iframe using Google Docs
<?php
/**
* WordPress shortcode loads a PDF file on your site in an iframe using Google Docs.
*
* Example: [embed_pdf width="600px" height="500px"]http://infolab.stanford.edu/pub/papers/google.pdf[/embedpdf]
*/
function embed_pdf($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('embed_pdf', 'embed_pdf');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment