Open PDF files in browser from SharePoint 2010

By default, SharePoint 2010 doesn't allow you to open the PDF files directly in the browser, Instead it prompts a "Save" Dialog box. This is because of the Web application's general settings. We can open pdf instead save.
open pdf document browser sharepoint 2010

To Make SharePoint 2010 to Open PDF documents in browser: Go to Central Administration >> Application Management >> Select the web application >> and click on "General Settings".

Now in "General Settings" Dialogue box, set the "Browser File Handling" to "Permissive". Now you can open PDF documents in browser from SharePoint 2010.
Lets use PowerShell to instruct SharePoint open PDF not save:
#Get web application 
$WebApp = Get-SPWebApplication ""
#Set property as Permissive
$WebApp.BrowserFileHandling = "Permissive"
#Update the changes

BrowserFileHandling at List/Library Level:
In some cases, BrowserFileHandling setting of a list or library may override web application setting. Here is how we can reset:

#Get the Site collection
$site = Get-SPSite("")

#Get all webs
foreach ($web in $site.AllWebs) 
    write-host "Processing  $($web.Title)"
   #Get all lists
    foreach ($list in $web.Lists) 
          #Check the browserfilehandling setting
           if($list.browserfilehandling -eq "Strict") 
              Write-Host "Changing " $list.Title
              $list.browserfilehandling = "Permissive";

Bother this will open other security holes? use AllowedInLineDownloadedMimeTypes

SharePoint 2010 determines whether to Open the file in browser or not based on the "AllowedInlineDownloadedMimeTypes" type  property of the web application. You can add/remove File types to this property collection to control the behavior.

Get the AllowedInLineDownloadedMimeTypes:
$WebApp = Get-SPWebApplication <web-App-URL>

Add a File Type to Allowed Inline Downloaded Mime Types:
$WebApp = Get-SPWebApplication <web-App-URL>
$WebApp.AllowedInlineDownloadedMimeTypes.Add("application/pdf" )

#For Flash files, use: 

A bit cleaner code would be:
$webApp=Get-SPWebApplication ""

If ($webApp.AllowedInlineDownloadedMimeTypes -notcontains "application/pdf")
  write-host "PDF File type added"
  write-host "PDF File type already exists!"

$WebApp = Get-SPWebApplication <web-App-URL>

Found the Remove works only for newly uploaded files after this change.

Open PDF Files in Adobe Reader application Instead of Browser:

We can open PDF in new window (in Adobe Reader's application or any client application which can handle PDF) from SharePoint. By default it opens in browser. In fact, this is based on the client settings. If you want to open PDF documents in Adobe Reader, instead of the same browser window: Open Adobe Reader, Go to: Edit >> Preferences >> Category: Internet >> Uncheck the option "Display PDF in browser ". 

However in latest version this option has been removed! So the remedy is: Disable Adobe reader add-on in browser. Here is how:
Go to Internet Explorer >> Tools >> Manage Add-ons >> Select "Adobe PDF Reader" and disable it! 
Open PDF Files in Adobe Reader Instead of Browser
Now, when you click on any PDF file, they'll be opened in Adobe Reader instead of browser.

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.