Embedding PDF’s into SharePoint 2010 pages
Recently I was asked by a client to see if you can embed a PDF into a SharePoint page. It turned out to be surprisingly easy!
I am assuming that you are using Wiki pages in your team sites in this example. Either way you have to put the embedded code into a Content Editor Web Part for this to work. If you put the code to a standard page then SharePoint will strip out the tags and this will not work ![]()
First you need to find the URL to the PDF that you wish to view, after that you are ready to go!
Step 1)
Add a Content Editor Web Part to the page
Step 2)
Click on the ‘Edit HTML Source’ button for the Content Editor Web Part (not the page)
Step 3)
Add the following code:
<object><embed src="FILENAME.PDF" height="850" width="850" type="application/pdf"></embed></object>
Where:
- src = The URL of the file, remember to put in a server relative URL to this!
- height = height of the rendered PDF
- width = width of the rendered PDF
Click on Save and you should see your PDF rendered out just like the example below! By the way this book by Phil Wicklund is awesome, check it out here.
Category: How To





[...] Embedding PDF’s into SharePoint 2010 pages [...]
What is about the SharePoint 2010 Blog Sites.
Do you have also a solution for blog entries?
I tried, but SharePoint remove the code automatically.
[...] empfiehlt HTML Code (und HTML Code generierende Java Scripts) einzubetten z.B. durch Änderung des HTML Codes der Seite mit dem Sharepoint Editor oder mit dem Sharepoint Designer. Dabei scheint es aber viele [...]
Great post. Also, if you want to do this dynamically a colleague of mine did a good article to compliment this one:
http://www.inspiredbytechnology.com/index.php/2011/03/31/embedding-a-pdf-object-in-a-sharepoint-2010-web-part-using-c/
I tried this out, it looks like it works, but once I click save Sharepoint changes the HTML code.
Any suggestions?
Hey Michael,
Are you sure that you are adding in the content into a Content Editor Web Part? If you are doing it directly on a page then it will strip out the HTML
I’ve actually done something similar with DVWP’s. I created a template with will dynamically render the file directly in SharePoint. Doesn’t matter what is chosen as long as you can embed it into a web page, it’ll render. Here’s a demo: http://spdwiki.com/SitePages/DocumentDashboard.aspx?docUID=2
and the codeplex project:
http://spxslt.codeplex.com/discussions/235951
Cheers,
Matt
Hey Matt!
That is cool.
Thanks for the comment.
I am having the same problem as Michael. How do I ensure that I am editing the HTML on the Content Editor Web Part? There is no button on that web part properties.
When I edit the HTML coed in the Content Editor Web Part the preview shows great, though a message says that the code “may have been modified”. When I click OK or Apply, the pdf disappears and shows a blank screen.
Hi!
Im having the same problem as the other guys. It looks good in preview but when I save I get a message that my code might have been modified and then the webpart turns grey. When I go back to look at the code it has indeed changed and now looks like this:
dont think the code was posted.. wierd.. i’ll try again, this time with a dot inside the object:
.
Hey Marcus.
Make sure that you are editing the HTML in the CEWP and not on the page that it is embedded in.
Hi,
Is it possible to do that thing dynamically. I want to embed pdf-documents from a list. So whenever you select a pdf-document in that list or library it will be displayed in a frame?
Any idea?
Matt Bramer,
That is a good example of displaying PDF into sharepoint page. I am looking to do the same but I like to know how to inject all that code into sharepoint page?
I mean do i have to add data view web part and then add provided code?
Or do i just add Content editor webpart?
The example shows that there is a ASPX dropdown which pass parameter to display appropiate PDF (files).
Please provide any helpful details based on your experience.
Great useful tip
Hi and thanks for this great solution. I am trying to do the same with .docx files but nusuccessfully yet. Any help would be appreciated.
Thanks in advance
Hi,
I have the same problem like Kirk and Marcus has.When I edit the HTML code in the Content Editor Web Part the preview shows great, though a message says that the code “may have been modified”. When I click OK or Apply, the pdf disappears and shows a blank screen.I’m using IE8 and sharepoint 2010.Can anyone please add the screenshot of the entire HTML code in CEWP? I’ve been trying since long time but I’m still stuck with this issue.
Your demmah is resolved – the code and (steps -1) are corrrect and works great; the (-1) is for one missing note.
Step 1a. Before you do step 2, click in the area below the Web-Part’s name, and it will work!
Happy Coding!