No “Open” option for PDFs on select SharePoint 2010 sites

Got an interesting problem when I came in today. A user had two SharePoint subsites within the same site collection. After choosing “Read-Only” after clicking on a PDF document in a document library, the user would be presented with the option to “Open” or “Save” the file in one site; on the other, there was no “Open” option.

At the root of this is one of SharePoint 2010’s new security features. Browser File Handling is a property that can be set at the Web Application level, and requires that certain files be downloaded to the user’s computer instead of opened inside the browser. By default, this setting is enabled (set to “Strict”). Setting this permission to “Permissive” will allow files to be opened inside the browser (the default behavior for SharePoint 2007). More information on Web Application general settings can be found here:

http://technet.microsoft.com/en-us/library/cc262107.aspx

However, this was already the setting on the web application being used, and there is no site-collection/site specific setting. So what gives?

As it turns out, sites that have been migrated from SharePoint 2007 may not necessarily respect the “Strict”/”Permissive” settings. While newly created document libraries will adhere to the web application’s settings, some existing libraries may need to be manually updated. The blog post here provides information on how to fix it.

http://nerdtastictips.blogspot.com/2010/08/sp2010-forces-users-to-save-pdfs.html

Notice that the post’s author uses a check on the document library’s title for the word “Document.” If not all of your document libraries are named as such, you can use this code instead, which looks for the Document type instead and changes all of the site’s libraries (that are of type Document, anyway).

foreach ($list in $rsrWeb.Lists) { if($list.basetype -match "Document") { if($list.browserfilehandling -eq "Strict") { $list.browserfilehandling = "Permissive"; $list.update(); $site.url, $list.title, $list.browserfilehandling} } }

So, the full procedure to fix this goes as follows:

  1. Start the SharePoint 2010 Management Shell.
  2. Link the $site variable to the site collection.
    $site = Get-SPSite("<site>")
  3. Open the site.
    $web = $site.OpenWeb()
  4. Open a document library on the list.
    $list = $web.GetList("http://mysubsitecollectionurl/List");
  5. Change the browserfilehandling property.
    $list.browserfilehandling="Permissive"
  6. Optionally, change the property on all lists in this subsite.
    foreach ($list in $rsrWeb.Lists) { if($list.basetype -match "Document") { if($list.browserfilehandling -eq "Strict") { $list.browserfilehandling = "Permissive"; $list.update(); $site.url, $list.title, $list.browserfilehandling} } }

Note that you will need to start from step 1 again if you are working on multiple sites – during the process the $site variable will get linked to the subsite.