Thursday, June 7, 2012

Enabling in browser support for PDF


A very old post I forgot to publish about enabling SharePoint browser support of PDF


If you have a default SharePoint 2010 setup you would notice that when you go to open a Pdf file SharePoint prompts you to save it rather than opening.

The cause of this behavior is SharePoint 2010 Browser File Handling. This property is on SharePoint Web Application level and its value determines how files are treated in the browser. “Strict” specifies that MIME content types which are not listed in “AllowedInlineDownloadedMimeTypes” are forced to be downloaded. “Permissive” specifies that the HTML and other content types which might contain script are allowed to be displayed directly in the browser. Source: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.browserfilehandling.aspx


“AllowedInlineDownloadedMimeTypes” is a collection of MIME types. This list of MIME types does not contain MIME type of Pdf documents by default. It is important to understand that by adding Pdf MIME type to IIS settings you will not solve this issue.

Solution #1 (via User Interface):

The solution is to change Browser File Handling property on Web Application level. For that you need to be a Farm Administrator. Steps to change Browser File Handling property:

  • Go to SharePoint 2010 Central Administration > Application Management > Manage Web Applications
  • Select the row of your web application
  • Click General Settings in the ribbon
  • Scroll down to Browser File Handling and select Permissive
part1-screen2.png
  • Click Ok

Now, your Pdf document will be opened in the browser.

By default, option is set to Strict when creating a web application. When set to Strict, a Pdf document (and other file types) can only be Saved (downloaded), but in Permissive mode, the Pdf document can be opened in the browser by default (this is a setting you can change. See Document Library Settings -> Open in the Client).



Limitation #1:
Once you enabled “Permissive” Browser File Handling, SharePoint will allow all documents be opened in the browser. Today, there is no “out-of-the-box” option to allow Permissive option for Pdf documents only.

No comments: