Living a SharePoint life

Wednesday, April 1, 2015

Adding PDF and other MIME Types to the Browser File Handling property

PDF Icon
By default a WebApplication in SharePoint doesn’t consider PDF files safe. If you click on one you may download it to your computer, but can’t view it with Acrobat inline in your browser. Learn how to change this behavior.

Using PDF files in SharePoint is however a very common task. You can store them in document libraries like every other document, open and save them or move them around. But not being able to open the PDF inside of the browser is a very annoying behavior and it forces the user to save copies on their local computer. Haven’t we installed SharePoint to get rid of local copies swarming around the office?

The reason SharePoint does not open PDF files in the browser is controlled by the Browser File Handling property. This property is configured on the SharePoint WebApplication level and determines how files (MIME Types) are handled in the browser. The property can be set to Strict or Permissiv. If set to Strict only unknown MIME Types not listed in the AllowedInlineDownloadedMimeTypes property are forced to be downloaded. If set to Permissiv on the other hand MIME Types which contain scripts or other active content are allowed to load directly in the browser.

How do you change the behavior then? There are two ways, the good and the not so good.

The lazy not so good approach is to globally change the property for all unknown MIME Types. This however can leave your server vulnerable for attacks against the user’s browsers. Because you do not only make it possible to open PDF, but also all other kinds of MIME Type like e.g. Flash, Shockwave, etc. which can be a threat to your safety.

  • To change the property, go to the Central Administration, Manage Web Applications
  • Select the WebApplication you want to configure and choose General Settings from the Ribbon menu
  • Scroll down until you find the Browser File Handling setting and change it to Permissive
  • At the end of the page select OK

The other way is where you have more control by adding PDF to the list of allowed MIME Types. This way you leave the property set to Strict. Then we only need to modify the properties collection with a little PowerShell script.
$webApp = Get-SPWebApplication http://host.domain.tld
Make sure the the MIME Type you are going to add isn’t already part of the list. Simply type $webApp hit return and look thru the list. If the MIME Type isn’t there you can continue with the next lines.
Of course you can add other MIME Types this way as well like e.g. for Flash content.

Featured Post

How are Microsoft Search quota consumed?

With Office 365 Search, Microsoft has created a central entry point for the modern workplace. In one convenient spot, users can access all ...