PDF MIME Type support in SharePoint 2010

‚ÄčOne of the more common questions about SharePoint 2010 is how to get PDF documents to open in the browser.  By default SharePoint only gives you the option to Save PDFs.  This is because the default configuration of SharePoint 2010 does not consider PDF documents safe for displaying in the browser.

If you do a search on this, you'll find lots of posts recommending that you turn off the Strict file handling in Central Admin to fix this.  The problem is Microsoft put this feature in to protect against scripting attacks, and turning it off for all file types is somewhat like turning off your firewall to get things to work.  It gets the job done, but it's not really the best approach.

The far better approach is to open up just the file types that you need.  PDFs are the most common, but certainly not the only ones.  We often need to store HTML mockups in SharePoint, and run into the same problem with them.

To resolve this just for specific file types, you need to set the AllowedInlineDownloadedMimeTypes property of the web application, typically through PowerShell.  Here is an example to change both PDF and HTML file types.

$webApp = Get-SPWebApplication("http://webappurl")
$WebApp.AllowedInlineDownloadedMimeTypes.Add("application/pdf")
$WebApp.AllowedInlineDownloadedMimeTypes.Add("text/html")
$WebApp.AllowedInlineDownloadedMimeTypes
$webApp.Update()

To run this you need to be on one of the SharePoint servers for the farm, and open the SharePoint 2010 Management Shell.  After executing this script, you have to restart IIS on each web front-end in order to activate this setting

iisreset /noforce.

Update: This also applies to SharePoint 2013 with the same steps.

3 Comments

Pedro Meira on 4/29/2013 4:55:29 AM

Hi, it works .... thanks. But I still have two issues: 1. Are theses changes persistent? 2. How can I associate an image to pdf mime type? the file opens ok, but the users don't view the pdf document icon on the list. thanks

MEdupe sadie on 6/27/2013 11:25:53 AM

i managed to run the script, i can see that pdf is listed in the AllowedInlineDownloadedMimeTypes, but still when i try to open PDf in sharepoint i get the save option instead of opening right away

Ray on 9/10/2013 1:09:41 PM

Hi. This service here allows you to easily and effectively edit, upload or download fillable PDF forms. http://goo.gl/RG3du2 You can fill out PDF form, save it, fax it, and email it.


Leave a Comment

Name  
Email (will not be published)    
Comment  
 
Enter both words, separated by a space.