This question cropped up a couple of times in the comments to the Adobe PDF Indexing blog post
How do you open a PDF in a web page on SharePoint?
Here is the method I use. There may be prettier and better ways to do it. If you know of one, please add a comment.
The short version:
- Take one Content Editor web part
- Enter <embed> tags containing the PDF fie as the source
The longer version:
- Upload the PDF you want to display to a SharePoint library. From within the library, right click the PDF file name and select ‘Copy Shortcut’ (this takes a copy of the full URL to the file)

- Add a ‘Content Editor’ web part to a SharePoint web page.
- If you’re using SharePoint 2007, it’s in the Miscellaneous group in the web part gallery
- If you’re using SharePoint 2010, it’s in the Media and Content group in the web part ribbon
- Edit the web part to insert your code
- Insert the code
- Click CTRL + V to paste the shortcut to the PDF file
- Then add the following code, using your shortcut in place of FILENAME.PDF
<object><embed src="FILENAME.PDF" height="600" width="600" type="application/pdf"></embed></object>
Here’s an example:
- Click OK/Save to save the code and then OK to save the web part
- You should now see your PDF file displayed in the web part. If required, adjust the height and width values until the PDF is displayed how you want it (preferably one full page in view). In SharePoint 2010, the code may have been modified a little – don’t panic.
- Save and publish your page (or Stop Editing, depending on what site template and version of SharePoint you are using)
Hey presto: One PDF document viewed inside a SharePoint web page. Cue free advertising for the last PDF that arrived onto my computer
Notes:
You must use the Content Editor web part for this task. If you try adding <embed> tags to a standard page control (for embedded content within the page), SharePoint will remove the tags when the page is saved and your hard work will disappear. If you’re running SharePoint with extra strong mints security, you may also find the <embed> tags are stripped out when attempting to save your work.
People will still need a PDF reader installed on their client in order to view the PDF embedded in the web page, just the same as when visiting any other web site with embedded PDFs.






[...] This post was mentioned on Twitter by Joining Dots, SharePoint Sharon. SharePoint Sharon said: New blog post: Embedding PDFs in SharePoint web parts http://bit.ly/bUgqMn [...]
Hi Sharon
Nice post! Do you think this same procedure would work with an excel spreadsheet?
thanks
Jake
Hi Jake
Many thanks
The easiest mechanism now for embedding spreadsheets is to use the new Office Web Apps which include the ability to embed PowerPoint presentations and Excel spreadsheets into web pages. There’s a post coming up on that… If you can’t use the new features, the older method used to be using the Office ActiveX controls but they were discontinued after Office 2003 and are hard to come by. The in-between method specifically for spreadsheets if you have SharePoint 2007 or 2010 Enterprise Edition would be to use the Excel Web Access web part that is included (not available if you’re on Standard Edition or Windows SharePoint Services/Foundation).
Hope that helps. Drop a note here if you have further questions.
This will work for every PDF saved in the library. Just copy the code and change the “FILENAME.PDF.” and you will have all the PDFs viewable. Trying to get it to work on Excel and word documents and it is not working.
Hi Frank, this tip is PDF-specific, it won’t work for any Office documents. I’ve just published a new post on how to embed Office docs into SharePoint but the news isn’t all good…
http://www.sharepointsharon.com/2010/10/embedding-office-docs/
THANKS! – not many of these blogs are so straightforward and work as simply and effectively as this. I sthere any way to turn off the PDF toolbar in the embedded viewer, or is that a viewer setting?
Thanks Jess
And as far as I’m aware, unfortunately no, you can’t turn off the toolbar as it’s part of the default PDF viewer.
Hi Sharon, thanks for the post. I am relatively new to SP2010 and tried to follow the steps, but they didn’t work. After I add the Content Editor web part, I want to edit to add the code snippet you suggest. Is the only way to edit the content in HTML form on the page level?
Any help is greatly appreciated as this looks like the perfect solution for what we are trying to do.
Thanks!
B
Hi Bryan
The only way to add the code is by adding the Content Editor web part and then, with the cursor placed inside the Content Editor web part, click the HTML icon in the ribbon. Paste the code in to the source editor. Make the changes to point to your filename, then save.
Any other method – such as clicking the HTML icon from within the page itself (instead of the web part), or going to update an existing content editor web part – will not work. SharePoint will strip out the code.
If you’re still stuck, I’m going to start a monthly Live Meeting session that anyone can attend and ask questions. We can walk through this procedure if you can attend. Will post an announcement in the next week.
Hi Sharon,
Thank you for above instruction.
I get as far as clicking OK to the HTML-text – and see the PDF-viewer.
But as soon as I select Save&Close everything disappears and I’m stuck with an empty Content Editor.
Maybe this is the high security level? But where do I check and edit the security level? I am full administrator, we are running Sharepoint Foundation 2010.
Thanks!
Hi Lea
First of all – you can only do it once. If the Content Editor doesn’t display correctly on save, you’d need to delete the web part, then add a fresh Content Editor web part and start all over again. If you ever go back in and edit the web part, it will strip out all code and you have to delete and start all over again. It’s quite a fussy little devil.
It might be a security issue – if you’re using a browser directly on the server, make sure the enhanced security mode is switched off and add the SharePoint URL to the Intranet zone. See how that goes.
Cheers and regards
Sharon.
Hi Sharon,
Great article! But all it shows on this system is a small grey icon. I’ve got the ifram installed, file type added and let SharePoint change to code (after being sure it keeps the ogject & embed codes). It does not show the pdf content. Only that strange little grey icon. Once I get this working I will need to test that the login id matches the metadata column for username (they can only see the one doc assigned to them).
Any suggestions? Thanks!
Rob
Hey Rob
Apologies if I’m checking the obvious but you do have Adobe Reader installed?
I’ve been using a similar technique on my SharePoint site. One complaint I get is that the pdf reader (and also Word) get cropped on the left and right sides, which some find aesthetically displeasing. I see that your example has the same problem. Is there any known cure?
Thanks.
Hi John
I don’t know. In this case, we’re using the embedded controls provided by the software. You could try a different PDF reader/control but afraid I’m not much help here.
Cheers and regards.
Hi Sharon,
Great article! In your article “Sharepoint 2010 and Adobe PDF”
Aaron and Dave ask if there is a way to prevent saving and printing. You answered that you would use server control stream through Adobe Flash Player.
(Cool recommendation!)
Is there also an article about how to do this in Sharepoint?
thx, Holger
Hi Holger
From the SharePoint side, you’d still just insert the embed code but for a different type of player. One that doesn’t include the options to print, save etc. If you look at sites like Scribd and Slideshare, people can choose the options available for documents uploaded, such as whether or not people will be able to print, download or embed. The features are outside the player, so when you embed you just get a player – can scroll through the pages/slides but nothing else.
Hope that makes sense.
All the best
Sharon.
You CAN turn off the scroll bars etc..
take a look here
http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf
Thanks Robert, haven’t delved too deep into what additional parameters can be added to the embed code. Good to know it can be done and thanks for sharing the link.
Hi Sharon,
This post was helpful. Do you know if there is a way to connect the content editor with a document library or a treeview list of documents? So when you click on a document in the library it will show up in the editor. Thanks.
Hi Tanya
Thanks. Off the top of my head, no I don’t. You can do a menu dropdown for a media player web part (to pick a video to watch) so I’m guessing could maybe hack that to do something similar but it would be a manually created menu, not automatically created by pointing at the document library.
The easiest to implement but takes manually work would be to create a page per document, and then they can be accessed via the sidebar navigation by simply clicking each page. Extra work but easy and stable to use.
I would love to use this, but it just plain isn’t working…keeps stripping the code. So in the HTML editor, I paste the code along with the path to the file and I click ok at the bottom. It takes me back to the page in edit mode and I can see the .pdf displayed in the content editor web part.
next, I am clicking Save & Close on the page. At this point, I am still looking at the page and can see the content editor web part, but my .pdf is no longer displayed. Am I missing something?
Hi Zane
It’s tricky little beast to get working. The problem will almost certainly be in your security settings – either the browser or how SharePoint has been configured.
One possible option would be to configure the content query web part externally, then import it into SharePoint. It’s just an XML file when all is said and done. Haven’t given this a try (will when I’ve got one of the VMs powered up), but drop a CQWP onto page, type something so it has some HTML content. Then export to your desktop. From the desktop, right-click and open in Notepad or similar. You’ll see all the XML tags storing the properties and content of the CQWP. You should be able to find the line containing the HTML content. Insert what you need there and then try importing back in.
how we can embed the excel file in the same way?
Hi Komal
See related blog post http://www.sharepointsharon.com/2010/10/embedding-office-docs/
Excel is easiest of the Office apps if you have SharePoint Enterprise edition….
Regarding the amount of possible PDFs there could be on one SharePoint site. Is there a way to have a PDF file reference back to only one page with that content editor on it? So you don’t have to individually create the same code for different files.
Hi Daniel
You could probably do it with scripting but if you have lots of different files, just letting the PDF open on click may be a more efficient approach.
Great post