various shenanigans.

Displaying PDFs in the browser from Sharepoint 2010

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.

“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 Part 1:
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
Click Ok

Solution Part 2:
You may still get prompted to open PDFs with the Client Application. Adding the MIME type will allow you to open the PDF in the browser.
Here is a Powershell script to affect this.

$mimetypes = “application/pdf”,
$webApp = Get-SPWebApplication http://portal

foreach($mime in $mimetypes)
{
If ($webApp.AllowedInlineDownloadedMimeTypes -notcontains $mime)
{
Write-Host -ForegroundColor White “Adding MIME Type “$mime
$webApp.AllowedInlineDownloadedMimeTypes.Add($mime)
$webApp.Update()
Write-Host -ForegroundColor Green “MIME Type added and saved.”
}
Else
{
Write-Host -ForegroundColor Yellow $mime” MIME type is already added.”
}
}
After executing this script, you have to restart your IIS in order this setting to get active: iisreset /noforce.

Close Bitnami banner
Bitnami