Thursday, November 10, 2011

Tips to resolve SharePoint 2010 users are prompted to save PDF file instead to open directly issue

We have SharePoint users reported an issue - users are prompted to save PDF files instead of opening directly when they try to open the files.  I looked at the issues and it has been addressed by several people for different directions. However, there is no easy way to verify the root cause for end users. In this blog, I will provide an simple way for end users to verify whether you have any open PDF file issues for specific library. Here is the details. 

Issue summary – In SharePoint 2010, users are prompted to save PDF files instead of opening directly when they try to open the files on some libraries. You could see detailed description in here. 

Root cause and solutions – In SharePoint 2010, there is a setting called “Browser File Handling” on both webapp level and library level that you could adjust to change this behavior. If the value has been set to “strict” instead of “permissive”, users are prompted to save PDF file.  Please note the setting on the library level is hidden value and will overwrite webapp level setting. As a result, if “Browser File Handling” is set up as  “permissive” on webapp level but as “strict” on library level, users will be prompted to save file.  You could follow the following steps to check and adjust the setting. 

       1. Browser File Handling setting on webapp level - You could use central administration UI or powershell to view/change the setting.

Go to Central Admin > Application Management > Manage Web Applications > Select the web application > Click General Setting in the Ribbon > Select “Permissive”  for “Browser File Handling” setting. You could use powershell to update all webapp setting to “permissive”

Get-SPWebApplication | ForEach-Object {$_.BrowserFileHandling = “permissive”; $_.update()} 

2. Browser File Handling setting on library level – You could not use SharePoint UI to view and change the value. You could use powershell or API to view and change the value. Here is a simple way I would prefer for end user to view  “Browser File Handling” hidden value for any list library. 

Use SharePoint designer to open the site. Then click the list library and find the ID (GUID) for the list. Then use the following URL http://<servername>:portnumber/<siteURL>/_vti_bin/owssvr.dll?Cmd=ExportList&List=<listHUID> to view the list settings. 

One example is listed below.


Of cause you still could use the following powershell to view and update the value. 

Add-PSSnapin Microsoft.SharePoint.Powershell
$site = Get-SPSite("http://sbx01/sites/Harry")
$web = $site.OpenWeb()
$list = $web.GetList("http://sbx01/sites/Harry/Shared Documents")
$list.browserfilehandling                       //list the value “Strict” is the return for example

$list.browserfilehandling = "Permissive"
$list.update()                                             // set the value to “Permissive”
$list.browserfilehandling                      // list the value again  

You could use the script published to loop through the site collection to update all list libraries through powershell.   One example is to loop through one web.

Add-PSSnapin Microsoft.SharePoint.Powershell
$site = Get-SPSite("http://sbx01/sites/Harry")
$web = $site.OpenWeb()
foreach ($list in $web.Lists) 
     if($list.browserfilehandling -eq "Strict") 
          $list.browserfilehandling = "Permissive"; 
          $list.update(); $site.url, $list.title, $list.browserfilehandling

After you update both “Browser File Handlingsettings on webapp and list library level to “Permissive”, you should open PDF file directly.  Please remember, you should verification the setting again by browsing URL like http://<servername>:portnumber/<siteURL>/_vti_bin/owssvr.dll?Cmd=ExportList&List=<listHUID>.

1 comment:

  1. Hi Harry, I'm getting this error:

    The following exception was thrown when trying to enumerate the collection: "Ac
    cess is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))".
    At C:\Scripts\Libraries.ps1:11 char:8
    + foreach <<<< ($list in $web.Lists)
    + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemExceptio
    + FullyQualifiedErrorId : ExceptionInGetEnumerator

    Could you please advise?