Opening PDF Files in SharePoint 2010

If you’ve installed SharePoint 2010, you may have noticed a change in behaviour of any PDF files that you may have stored. Previously, they would open directly in the browser, but now the user is prompted to save the file to the disk. This is due to a new security feature in IE8 that SharePoint 2010 respects. In order to allow the old behaviour, you must set the browser file handling options to “permissive” as opposed to “strict”.

This change is done at the application level. First, navigate to Manage Web Application within Central Admin, select the application in question, and choose General Settings on the ribbon.

image

Once in the settings screen, scroll down and find the section for Browser File Handling, and change it to permissive.

image

It goes without saying that this is less secure, but if you trust your PDF files, you should be good to go. Of course,as always,no warranties, express or implied…

Thanks to Mike Hacker’s Blog where I originally came across this.

UPDATE – SEPT 7 2010

I just ran across a case where this does not fix the problem. PDFs and all file types including HTML were prompting the user for download. This was not consistent, as it was happening in some libraries and not others. As it turns out, it’s a bit of a bug, and document libraries will not always inherit the browser handling attribute.

You can test this by running the following Powershell:

$site = Get-SPSite(“https://mysitecollection")
$web = $site.OpenWeb("/MyWeb")
$list = $web.GetList("https://myweburl/LibraryName")
$list.browserfilehandling
If it returns “Strict”, then you have a problem. The good news is, you can set it:
 
$list.browserfilehandling = “Permissive” ;
$list.update();
You should probably loop through your entire site collection and set this value to be safe. The powershell to do this can be found  on Nerdtastics Tips, which is where I found the fix in the first place.

 

UPDATE – SEPT 10 2010

As opposed to hunting through your sites to find the problems, I wrote the below PowerShell script that take the URL for the site collection as an argument, and sets the permissive flag on any lists set to strict.

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$siteURL = $args[0]
$webname = $args[1]
$site = Get-SPSite($siteURL)

foreach ($web in $site.AllWebs) {
    Write-Host "Inspecting " $web.Title
    foreach ($list in $web.Lists) {
        if($list.browserfilehandling -eq "Strict") {
            Write-Host "Changing " $list.Title
            $list.browserfilehandling = "Permissive";
            $list.update();
            $site.url,
            $list.title,
            $list.browserfilehandling
        }
    }
}

UPDATE – OCT 5 2010

I’ve run into more situations where this doesn’t solve the problem. I created a new post describing them here.

18 thoughts on “Opening PDF Files in SharePoint 2010

  1. Pingback: Adding PDF Icon or Creating a Site From Template triggers Prompt for Download In SharePoint 2010 | The White Pages

  2. Ben Barr

    Thanks for the information. A quick question; for the arguments, I see where $siteURL is referenced in the script, but not $webname. Am I missing it somewhere? Also, for the siteurl, does it need to be included in quotes?

  3. Ben Barr

    Please ignore my previous comment; I got it figured out. Thanks so much; this saved a ton of work!

  4. Pingback: Cannot open files from document libraries without save « Tech Talk PT

  5. Michal Krlin

    Does it apply to sharepoint foundation too ? Have trouble executing powershell scripts.

  6. John White Post author

    It does. However, you may be better off getting the December Cumulative update, which fixes the core bug.

  7. Pingback: Searching PDF's in Sharepoint 2010

  8. veena

    Good article. thanks for sharing.

    What about partial downloading of pdf in sp 2010. We have lots of pdf files uploaded to the doc lib of 2010. when the user clicks on the document, the document should open partially so that when the user scrolls down the pages, the pages are gradually loaded. This we require mainly to improve the response time taken. Whether there are other 3rd party tools if not possible OOTB or code.

  9. Pingback: Permissive and PDF and Scripting Attacks « Sladescross's Blog

  10. John White Post author

    Sladescross – while I agree that you are correct, these things must be evaluated in the context of the threat level. Also – saying “no” to a customer isn’t always the best course of action.

    Veena – I’m afraid that partial rendering sounds like a custom solution to me.

  11. Dan Peters

    Ran through this fix in July 2011, and it worked great for me.
    However, since then I’ve applied W2KR2 SP1, and now I get
    Exception calling “Update” with “0” argument(s)
    CategoryInfo: NotSpecified (:) [], MethodInvocationException
    FullyQualifiedErrorID: DotNetMethodException

    Has anyone else experienced this, or found a solution?

    We’re progressing towards applying the CU, but I have a more immediate need to get this fixed.

    tx

  12. Brian R

    Thanks! Your script helped a lot. Had the same problem.. lists weren’t always inheriting the farm setting.

  13. Andres

    I´d like to see a preview of the pdf content when a user selects the row in the library or on mouse over.
    It would be like google web preview. It´s that possible? Thks

  14. charles

    We currently have a problem in our sharepoint site. it’s sharepoint 2010 sp1 with june cumulative update. The users will like to open pdf in browser as against downloading it . I have done a bit of search online and this is what have done so far. 1. i have added add PDF MIME type to this list using AllowedInlineDownloadedMimeTypes.Add 2.i have checked the browser settings to enable the the adobepdf reader 3. i also checked the option of display pdf in browser for my adobe settings. Non of these solved the problem. can anyone help? what next can i do to get this fixed. Cos i’ve done almost all the solution i can find on the internet. is there anything more i can do ? Thanks

Leave a Reply

Your email address will not be published.