PDF files can not be opened directly, only saved

Quite a few times now I have visited a customer to do some kind of support on their SharePoint 2010 environment. On a few occasions I got questions by employees who are complaining why they cannot open the PDF files from their portal, but have to save those files first. Very annoying… In this post I‘ll explain why and show you a way to solve this problem.

The explanation

By default, SharePoint 2010 doesn’t consider PDF files to be save for opening in the browser. SharePoint 2010 adds an additional security header and is handled by the browser (especially IE8 and later). The browser forces the user to save the files first on the local disk before opening it. There is a list of allowed MIME types to be opened in the browser directly and PDF files are not on that list.

SharePoint2010_PDF_0

The Solution

It is a simple web application setting to make you the hero of the day! The setting is called Browser File Handling and can be found at the General Settings of the web application.

SharePoint2010_PDF_1

The default value is Strict. This means only those MIME types on that list are allowed to be opened directly in the browser. If you set it to Permissive, no security headers will be added and your browser will opened any file directly.

SharePoint2010_PDF_2

Here you go… you’re the hero now!

…but you could do better!

What if you could extend that allowed MIME types list with PDF? You would still have control of the secure environment and open the door only for PDF files. PowerShell to the rescue! As I mentioned earlier, it’s a web application setting and with PowerShell you can access this list by calling the property AllowedInlineDownloadedMimeTypes.

To see what’s allowed out of the box execute this little script:

$webapp = Get-SPWebApplication <your webapp url>
$webapp.AllowedInlineDownloadedMimeTypes

The result looks like this (showing just a part of it):

:

application/fractals

application/internet-property-stream

application/liquidmotion

application/mac-binhex40

application/ms-infopath.xml

application/msaccess

application/msword

application/oda

application/oleobject

application/onenote

:

All we have to do is add our PDF MIME type to this list:

$webapp = Get-SPWebApplication <your webapp url> $webapp.AllowedInlineDownloadedMimeTypes.Add(“application/pdf”)

$webapp.Update()

There you go again. You’re even the IT department’s hero of the day!

Share