Shortcode: Embed a PDF in an iframe

Add following code where you want to display it.


[embedpdf width="600px" height="500px"][/embedpdf]

Add following snippet to “functions.php”


function cwc_viewpdf($attr, $url) {
    return '<iframe src="' . $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');

Courtesy: snipplr

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>