Open PDF files Dynamically in Content Editor Webpart

Problem:

Load dynamic pdf file through page viewer or content editor wepart

Solution:

Basically, if you had more than one pdf to view; it is not that easy to insert a pdf file onto a SharePoint page (through page viewer Webpart).  To fix this, I used a query string and a small java script to dynamically load the pdf on my page.

You have to first create a url.  It consists of the url of the pdf documentl.

Example:

http://<Server>/<Site Collection>/site/pages/<YourPage>.aspx?pdfurl=/sites/demojoseph/Lists/List Read Attach/Attachments/1/jebaticket.pdf

Add the following code in the source of a Content Editor Webpart

The above Javascript write an embed tag into the pdfHolder tag. In the embed code, you will put the address of your pdf library. The urlof the pdf file, which we got from the query string(pdfurl), gets placed here. You can adjust the width and height.

Advertisements

About Joseph Velliah
As a SharePoint Developer my professional interests tend to be technical and SharePoint focused. I run a blog at "SP RIDER" where you can expect to read HOW TOs and scenarios that I run into during my day to day job. I hope my posts will give back a little to the community that is helped me.

5 Responses to Open PDF files Dynamically in Content Editor Webpart

  1. Hi Joseph,

    I found your article really helpful. but what I want to know is, if I pass on the pdf url, would that in anyway expose the file location and allow user to get onto that address, if i am storing the files in one of the folders in sharepoint?

  2. Jewell Ellis says:

    It doesn’t seem to be working for me, al li see is “No review document selected” Where am I supposed to insert the query string I created?

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: