PDF MIME Type support in SharePoint 2010

|
Published

​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.

Latest Articles