show pdf in wordpress blog or website

Many people want to show there pdf files in wordpress blog. PDF is really popular format for showing the document with graphics and text and design and graphs. Without loosing the quality of text and graphics if we need to show the content then PDF is really nice format.

pdf in wordpress

pdf in wordpress
pdf in wordpress

In business world for presentation purpose all people mostly use the PDF document. Some wp developers asked about showing the pdf in wordpress.

For without any issue if you want to show the PDF document then you need to just open functions.php file and put following code in that file.
Following code I written for creating the shortcode in wordpress

function pdflink($attr, $content) {
return '<a href="http://docs.google.com/viewer?url=' . $attr['href'] . '">'.$content.'</a>';
}
add_shortcode('pdf', 'pdflink');

For showing link of PDF file in article or post you need add the following lines in the article.

[pdf href=”http://yoursite.com/linktoyour/file.pdf”]View PDF[/pdf]

Note: Upload the PDF file to your wordpress and then get the path of PDF file and then put above lines in article.
Change the path as you required.
Above code will create pdf link for your pdf document in your site.

If you does not want to create PDF link in your site and you want to show the pdf doc in your site then use following code.

function pdfshow($attr, $content) {
return '<iframe src="http://docs.google.com/gview?url='.$attr['href'] .'&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>';
}
add_shortcode('pdfshow', 'pdfshow');

For showing the PDF file in article or post you need add the following lines in the article.

[pdfshow href=”http://yoursite.com/linktoyour/file.pdf”]View PDF[/pdf]

We are looking for pdf in wordpress post, wordpress pdf tutorial,  wordpress tutorial, wordpress documentation pdf, wordpress ebook pdf, wordpress book, wordpress ppt, wordpress tutorial for beginners this for wordpress. Here we can add the pdf support using my code in your wordpress sites.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

One thought on “show pdf in wordpress blog or website”

Leave a Reply

Your email address will not be published.