Here is how you can tell SharePoint 2010 site to open the PDF files in the browser instead of prompting the user to save or open the PDF. This will be a great option to the most of end users. This needs simple Powershell scripting run on the server. Below is the code we should use:
# <#
# .DESCRIPTION
# This script adds new MIME type to "AllowedInlineDownloadedMimeTypes" property list of defined SharePoint 2010 Web Application.
#
# Script prompts you for MIME type and Web Application URL.
#
# Code shall run in context of Farm Administrators group member.
#
# .NOTES
# File Name : Add_MIME_Type.ps1
# Author : Kamil Jurik, WBI Systems a.s.
# Created : 11/12/2011
#
If ( (Get-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null ) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
Get-SPWebApplication
$WebApp = Get-SPWebApplication $(Read-Host "Enter Web Application URL")
Write-Host "Mime Type Examples:""application/pdf, text/html, text/xml"
If ($WebApp.AllowedInlineDownloadedMimeTypes -notcontains ($MimeType = Read-Host "Enter a required mime type"))
{
Write-Host -ForegroundColor White "Adding" $MimeType "MIME Type to defined Web Application"$WebApp.url
$WebApp.AllowedInlineDownloadedMimeTypes.Add($MimeType)
$WebApp.Update()
Write-Host -ForegroundColor Green "The" $MimeType "MIME type has been successfully added."
} Else {
Write-Host -ForegroundColor Red "The" $MimeType "MIME type has already been added."
}
The powershell script do the magic for us. Below is the explanation.
- It is taking the web application url as input
- And if the web application is not allowed the the PDF files MIME type to it's allow downloadable mime types collection then it will add it.
So, once you run the code the files will be open up in the browser instead of prompting the user. The server will not allow PDF files by default as it think PDF files are not secure.
Note: The script should run with the account who has FARM administrator level access.
For more details about it: please check
technet article.