Open PDF files Dynamically in Content Editor Webpart


Load dynamic pdf file through page viewer or content editor wepart


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.


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.

5 thoughts on “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?


    1. I’m trying to add a .pdf viewer to the Editform.aspx page. When a user licks edit they should see an open copy of the .pdf so they can insert metadata from within the file. will I be able to accomplish that with this solution?




Leave a Reply

Fill in your details below or click an icon to log in: Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.