How to Show PDF, Spreadsheet and Word file in WordPress post

My client want to display pdf files in the post, his website is powered by WordPress, although there are lots of plugins to achieve this task but the requirements was to display pdf content without installing any extra plugin. I have found a solution on WordPress API.

By using this piece of code you can easily embed PDF files into a a page or post for clients, so website visitors can read the PDF document right from the page. The process of embedding PDF files into a WordPress post is fairly simple by using the Google doc technology. This function not only enable you PDF documents but also you can embed Microsoft Word Documents, PowerPoint slides, Excel Spreadsheets, and other elements in your WordPress blog without loosing the quality of text, table and graphics [Dream Template]. Open up your function.php file and add following piece of code in it, which enable you to create a shortcode in WordPress:

function pdflink($attr, $content) {
return '<a href="' . $attr['href'] . '">'.$content.'</a>';
add_shortcode('pdf', 'pdflink');

Now for displaying  link of PDF documents, Microsoft Word Documents, PowerPoint slides, Excel Spreadsheets, and other elements in your WordPress blog in article or post you need add the following lines in the article.

[pdf href=””]View PDF[/pdf]

Upload the required file and get the file link and replace with, this will create  pdf link for your pdf document in your site. Although with WordPress latest version you don’t need to use this function to provide the link. WordPress by default now give this facility.


But we want to create PDF or document  link in to display the document content in page or post. So there are WordPress plugins and following code will help you to show the documents in WordPress post or page. Add following code in theme’s function.php file:

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

And now for displaying PDF or documents in article or post, add the following lines in the article as a shortcode:

[pdfshow href=””]

Upload the required file and replace this with your own download files link.

Embed PDF, Spreadsheet, and others with WordPress Plugins

Google Doc Embedder


Google Doc Embedder lets you embed several types of files into your WordPress pages using the Google Docs Viewer – allowing inline viewing (and optional downloading) of the following file types, with no Flash or PDF browser plug-ins required:


Html To Pdf On Fly For WP And Shortcode Style

Html To Pdf On Fly For WP And Shortcode Style

with this plug-in for WordPress you can create PDFs from HTML code on fly and save them in a specific folder of your blog. For example, you can create an invoice with this script and archive it.

  • Easy to use
    (just write your html and transform)
  • Include CKeditor, TCPDF and jQuery
  • Some configurable options for your PDF
  • “Downloadable” PDF
  • Preview PDF
  • PDFs Listing
  • Give PDFs links to your clients via shortcode created automatically
  • With shortcode you can show PDFs preview to your client and they can download PDFs
  • ou can style each shortcode and save its configuration


Web Grabber WordPress Plugin

Web Grabber WordPress Plugin

If you want to embed various contents from public web sites into your WordPress blog , then the Web Grabber WordPress Plugin is the perfect tool that will help you do that.
No frames or iframes involved! Real HTML content, grabbed form the web and displayed in whithin your blog just like you wrote it by yourself.


Agency Theme - First Impressions Are Everything     e-Business Express We Help Grow Your Business


5 out of 5 stars based on 234 rating(s).
  • Nur

    I am a WordPress, Website Developer and Designer, creator @ WP Arena, Provide Free WordPress consultation and can help to install WordPress in a secure way to small businesses and bloggers.