locked
SharePoint 2010 prompts to save PDF documents when opening. RRS feed

  • Question

  • Hello,

    Our users are being prompted to save PDF documents when clicking on them in SharePoint 2010.  We set the 'Browser File Handling' setting to 'Permissive' for the Web Application, but we are still being prompted for some of the PDF files.  Some PDF files open fine, though.  Doug

    Friday, October 8, 2010 6:19 PM

Answers

  • I have run into this issue myself. In my case I had the following scenario:

    • Initially, my web application had 'Browser File Handling' set to 'Strict' (which is the default when creating a web application)
    • Created a site collection, then a custom document library, and saved it as a template
    • Created a new document library using the template
    • Changed the web application 'Browser File Handling' to 'Permissive'
    • Found that I still was prompted to save PDF files before opening in the document libraries created with my template. Document libraries created with the out-of-the-box templates worked as expected.

    I am sure there are more scenarios where this issue would surface, perhaps saving a web as a template before changing 'Browser File Handling'. Although I should do more testing for a complete list of scenarios, I needed to find out what was the cause. So I investigated.

    Each Document Library in SharePoint 2010 actually has a property titled BrowserFileHandling that is set based on the BrowserFileHandling selection at the Web Application level. In the scenario I described above, I have found that the inheritance of this property does not always behave as you would expect.  Using PowerShell (you could also use the object model) you can take a look at the BrowserFileHandling property at the Document Library level as this is not exposed in the UI.

    Here is some PowerShell to help and please note this is used in the SharePoint 2010 Management Shell

    #Get Web
    $web = Get-SPWeb "http://yourspweburl"
    
    #Get Document Library
    $docLib = $web.lists["Your Document Library Title"]
    
    #View all properties/methods of the Document Library and you'll see that BrowserFileHandling is a property
    $docLib | Get-Member 
    
    #See the current BrowserFileHandling setting for the Document Library
    $docLib.BrowserFileHandling
    
    #If you need to change it from Strict to Permissive
    $docLib.BrowserFileHandling = "Permissive"
    $docLib.Update()
    

    Even if the template scenario that I describe isn't your scenario you can certainly use the above PowerShell code to inspect, and if necessary, change the BrowserFileHandling property in a Document Library that is presenting the problem you describe.

    I hope this helps.

    C.

    • Edited by Craig Lussier Saturday, October 9, 2010 12:58 PM Added a few more comments
    • Marked as answer by DJoherl Tuesday, October 12, 2010 6:43 PM
    Saturday, October 9, 2010 12:49 PM

All replies

  • I have run into this issue myself. In my case I had the following scenario:

    • Initially, my web application had 'Browser File Handling' set to 'Strict' (which is the default when creating a web application)
    • Created a site collection, then a custom document library, and saved it as a template
    • Created a new document library using the template
    • Changed the web application 'Browser File Handling' to 'Permissive'
    • Found that I still was prompted to save PDF files before opening in the document libraries created with my template. Document libraries created with the out-of-the-box templates worked as expected.

    I am sure there are more scenarios where this issue would surface, perhaps saving a web as a template before changing 'Browser File Handling'. Although I should do more testing for a complete list of scenarios, I needed to find out what was the cause. So I investigated.

    Each Document Library in SharePoint 2010 actually has a property titled BrowserFileHandling that is set based on the BrowserFileHandling selection at the Web Application level. In the scenario I described above, I have found that the inheritance of this property does not always behave as you would expect.  Using PowerShell (you could also use the object model) you can take a look at the BrowserFileHandling property at the Document Library level as this is not exposed in the UI.

    Here is some PowerShell to help and please note this is used in the SharePoint 2010 Management Shell

    #Get Web
    $web = Get-SPWeb "http://yourspweburl"
    
    #Get Document Library
    $docLib = $web.lists["Your Document Library Title"]
    
    #View all properties/methods of the Document Library and you'll see that BrowserFileHandling is a property
    $docLib | Get-Member 
    
    #See the current BrowserFileHandling setting for the Document Library
    $docLib.BrowserFileHandling
    
    #If you need to change it from Strict to Permissive
    $docLib.BrowserFileHandling = "Permissive"
    $docLib.Update()
    

    Even if the template scenario that I describe isn't your scenario you can certainly use the above PowerShell code to inspect, and if necessary, change the BrowserFileHandling property in a Document Library that is presenting the problem you describe.

    I hope this helps.

    C.

    • Edited by Craig Lussier Saturday, October 9, 2010 12:58 PM Added a few more comments
    • Marked as answer by DJoherl Tuesday, October 12, 2010 6:43 PM
    Saturday, October 9, 2010 12:49 PM
  • two things you need to check 1st enable the PDF files in sharepoint:

    http://www.asksharepoint.com/archive/2010/08/03/enabling-adobe-pdf-in-sharepoint-2010.aspx

    2nd when you change the web application setting to permissive then after completeing the set you should reset IIS.

    http://www.asksharepoint.com/archive/2010/08/27/opening-pdfs-in-sharepoint-2010.aspx

     

    and another good stuff to read.http://social.msdn.microsoft.com/Forums/en/sharepoint2010general/thread/3e5b820f-9183-414e-a6f8-ec7d0e93d299

    hope this works

    thanks

    -ws

     


    SharePoint administrator, MCTS,MCITP
    Sunday, October 10, 2010 3:53 AM
  • Hi Craig and WS,

    Thanks for replying!  The site/document library was created with a template and I'm thinking that it may be the issue.   I'm going to run the PowerShell scripts provided to see if they fix the issue.  Thanks,  Doug

    Tuesday, October 12, 2010 12:56 PM
  • Let me know if the PowerShell route works for you.

    Cheers,

    C.

    Tuesday, October 12, 2010 12:59 PM
  • Hi Craig!

    That PowerShell script you provided was awesome!!!  Thank you!  Doug

    Tuesday, October 12, 2010 1:30 PM
  • Good find.  Thanks for posting the solution!
    Monday, November 29, 2010 3:22 PM
  • I must be doing something wrong. The line to get the document library fails with a "No object has been specified to the get-member cmdlet". The library in question is called "Financial". So, my cmds were:

    # $web = Get-SPWeb "htps://www.mysite.com/fpc"

    # $docLib = $web.list["Financial"]

    # $docLib | Get-Member

    [error]

     

    My library in question is:  https://www.mysite.com/fpc/prj/lm4905 "fpc" is the site collection and a managed path for that top level site. Any idea what I'm doing wrong? Thanks.

    - buck


    Buck in UF
    Tuesday, December 7, 2010 1:03 PM
  • Still can't get the PS to do what I want but, I did find this model object viewer on codeplex that does the trick. http://spm.codeplex.com/ This worked like a champ once I drilled down to the library in question. "SharePoint Manager 2010"
    Buck in UF
    Tuesday, December 7, 2010 2:09 PM
  • Fortunately, this issue is now fixed with december CU.

    http://tinyurl.com/33spckk

     

    Monday, January 3, 2011 3:40 PM
  • Hi:

    There is a better way to handle "Browser File Handle" issue. Take a look at my blog here: http://www.pdfsharepoint.com/sharepoint-2010-and-pdf-integration-series-part-1/

    Solution #2 addresses Pdf extension without exposing entire Web Application to "Permissive" browsing. Setting "Browsing File Handle" to "permissive" opens too many vulnerabilities with other file extensions.

    Thanks,

    Dmitry

    • Proposed as answer by radmantom Thursday, December 29, 2011 2:11 PM
    Thursday, March 10, 2011 7:59 PM
  • Hi Criag --

    You're awesome.

    I tested with the above powershell commands for a document library and it worked. My question is how to make it permissive for the complete site collection using powershell? Here is the scenario, I have created a new database and attached to an existing web application and then created a site collection. For some reason, some of the web application general settings are not being applied for the newly created site collection. I want to make "Permissive" for the entire site collection, the reason is i have 40 sub sites and 1000's of document libraries so i cant apply the Permissive separately for all the document libraries.

    Hope you can help me with this. We are going live with these project soon. So please help me if you know the solution for this.

    Thanks.

    Wednesday, September 14, 2011 4:15 AM
  • I am certainly willing to help - however this script would be more involved than the one I posted above. I'd need a little time to create such a script (very busy right now).

    I'll write one up over the weekend to achieve this goal. I'll post it once I am done. I hope this still allows you to make your deadline. In the mean time, create a test web application that you can test the script against once I can get it to you - I strongly recommend that you make these types of changes in a non-production development environment and then migrate it into a production environment. 

    Kind regards,

    Craig


    Senior Systems Engineer / SharePoint Architect | MSDN Profile | SharePoint Task Force
    Microsoft Community Contributor Award 2011 Recipient
    Thursday, September 15, 2011 11:27 PM
  • Hi Craig --

    You're the best !! Thanks a lot for your help :)

    We are going live on next Wednesday so we still have time. Thank you so much for spending time on this. I really appreciate that. If you can prepare the script for me then I would try that on the dev environment and if everything works fine then probably I will migrate it into the production.

    Thanks again.

     

     

    Saturday, September 17, 2011 12:20 AM
  • I have posted a PowerShell script to the TechNet Gallery at http://gallery.technet.microsoft.com/Set-SPDocumentLibrary-0426781c that will help you with what you need to do before your go-live day.

    Notwithstanding the December 2010 CU hotfix related to this issue (note I tested with the latest bits as of this writing SP1 and August 2011 CU), I am still not convinced that the BrowserFileHandling property issues in all scenarios have been corrected. With this said, given your scenario I have found that the Web Application BrowserFileHandling property doesn't always change the property in document libraries. I need to do more testing to form an opinion that there may be a bug...

    In order for complete disclosure, please note that you can also set specific MIME types to 'Permissive' within a Web Application (highly security conscience folks may wish to take this route) without setting the entire Web Application to 'Permissive'. In the Gallery post I provide a link to forum post that demonstrates how to do this in PowerShell.

    Please carefully read all the documentation especially the parameters and examples on how to execute the script. I've included a full help section and the script is well commented.

    The script has a -WhatIf switch so you can run the script and get a CSV report (it will be generated to the same folder where you execute the script from on your SharePoint server) of the document libraries in your site collection where the BrowserFileHandling property is set to 'Strict' that you wish to change to 'Permissive' without actually committing any changes. 

    The script is designed to execute against a SPWeb - set the Url parameter to the address of your site collection. In addition there is a -Recursive switch which will execute the script against all sub-webs as well - I know this is a requirement for you. By default, the script does not execute recursively so be sure to include this switch when you execute the script.

    The script by default will 'process' all document libraries in a SPWeb that are not hidden (the script does not allow for targeting hidden document libraries). This is equivalent to the Document Libraries list you'll see when you visit a webs 'View All Site Content' page. You can tell the script to target specific document library titles (the script takes care of determining whether or not that document library title exists within the web or not) so if you wish to target specific document libraries, you can do so.

    An example command that will recursively traverse your site collection (i.e. your site collection rootweb including all sub webs) and change all document library BrowserFileHandling properties from 'Strict' to 'Permissive' looks like this (note that a CSV report of changes will automatically be generated to the same folder where you execute the script from on your SharePoint server):

     

    c:\folderwhereyousavedthescript\Set-SPDocumentLibraryBrowserFileHandling.ps1 -Url "http://yoursitecollectionurl" -BrowserFileHandlingTypeToChange "Strict" -BrowserFileHandlintTypeNewValue "Permissive" -Recursive
    

     

    You can execute this command without committing any changes with the following and get a CSV report to analyze (the only difference is to include the -WhatIf switch):

     

    c:\folderwhereyousavedthescript\Set-SPDocumentLibraryBrowserFileHandling.ps1 -Url "http://yoursitecollectionurl" -BrowserFileHandlingTypeToChange "Strict" -BrowserFileHandlintTypeNewValue "Permissive" -Recursive -WhatIf
    

     

    If you have specific document library titles you wish to target, please review the examples I provided within the script.

    This script is similar to one I've had for quite some time - I just needed to modify it a bit in order to feel comfortable to release it to the public. Please be advised that this script is provided AS IS without warranty of any kind.

    Please let me know if you have any questions. I hope you like the script!

    I hope this helps,

    Craig

     


    Senior Systems Engineer / SharePoint Architect | MSDN Profile
    Microsoft Community Contributor Award 2011 Recipient
    • Edited by Craig Lussier Monday, September 19, 2011 4:38 AM added text
    Monday, September 19, 2011 4:15 AM
  • Awesome Craig !!

    Let me try this on the dev today and let you know how it goes. Thanks a lot for taking time. You have been a great help.

    Thanks.

    Tuesday, September 20, 2011 3:10 PM
  • I look forward to hearing your feedback - if you have any questions while testing the script in dev, submit a reply to this thread and I'll get back to you.

    Kind regards,

    Craig


    Senior Systems Engineer / SharePoint Architect | MSDN Profile
    Microsoft Community Contributor Award 2011 Recipient
    Tuesday, September 20, 2011 4:23 PM
  • Hi Craig -- For some reason it doesn't work for me. I dont know I'm I'm doing anything wrong but the script doesn't work as expected. Here is the screenshot.

    Here are the steps that i followed:

    1. Downloaded the script and moved to a folder on the C drive on the SharePoint web server (c:\script)
    2. Opened the Powershell 
    3. Step 1: c:\script\Set-SPDocumentLibraryBrowserFileHandling.ps1
    4. Step 2: Asked me for the URL: provided the site collection URL (http://samweb03:95/sites/testsite)
    5. Step 3: Asked me for BowserFileHandlingTypeToChange : Strict
    6. Step 4: Asked me for BowserFileHandlingTypeNewValue: Permissive.

    And doesn't ask me for recursive. Also the generated csv file is empty. Please see the screenshot attached. Do you what the problem is ? Please help.



    • Edited by rebel537 Friday, September 23, 2011 6:47 AM
    Friday, September 23, 2011 6:44 AM
  • Craig -- Do I have to make any changes to the script before running it ?
    Friday, September 23, 2011 6:48 AM
  • Sorry for the delay in my reply. You don't have to make any changes to the script.

    What the script is telling you is that within the SPWeb that you are running the script against, there are no document libraries that have BrowserFileHandling set to Strict. If there were no changes, the report will be empty.

    Try this to see if the document libraries are all set to Permissive. This will not change anything as the WhatIf switch is used - it will just create a report:

     

     

    c:\script\Set-SPDocumentLibraryBrowserFileHandling.ps1 -Url "http://samweb03:95/sites/testsite" -BrowserFileHandlingTypeToChange "Permissive" -BrowserFileHandlingTypeNewValue "Strict" -WhatIf
    

     

     

    Recursive is not required and therefore it will not prompt you. if you want to run the above recursively, against the specified web and all sub webs, run this - again this will not make any changes as the -WhatIf switch is used.

     

     

    c:\script\Set-SPDocumentLibraryBrowserFileHandling.ps1 -Url "http://samweb03:95/sites/testsite" -BrowserFileHandlingTypeToChange "Permissive" -BrowserFileHandlingTypeNewValue "Strict" -Recursive -WhatIf
    

     

    Now, if you want to run a report on all document libraries, recursively from the specified web and all sub webs that are Strict - run this:

     

    c:\script\Set-SPDocumentLibraryBrowserFileHandling.ps1 -Url "http://samweb03:95/sites/testsite" -BrowserFileHandlingTypeToChange "Strict" -BrowserFileHandlingTypeNewValue "Permissive" -Recursive -WhatIf
    

     

     

     

    Run the examples above all of which will not change anything in your environment and then get back to me. If you want to commit the changes, remove the -WhatIf switch.

     

    Let me know how this goes.

     

    I look forward to hearing back from you - we can take this conversation offline as well - feel free to email me:

    craig [at] craiglussier [dot] com

    I want to make sure this is working for you.

    Cheers,

    Craig


    Senior Systems Engineer / SharePoint Architect | MSDN Profile
    Microsoft Community Contributor Award 2011 Recipient

    • Edited by Craig Lussier Friday, September 23, 2011 8:33 PM
    • Proposed as answer by rebel537 Tuesday, September 27, 2011 1:33 AM
    Friday, September 23, 2011 8:24 PM
  • Craig --

     

    You're like the SharePoint "GOD". what can i say, I ran the script and it worked great without any issues. You saved my time.

    Your script works like a charm. Thank you so much for your concern and also for taking time in preparing the script for me.I'm so relieved now.

    You're the best. Thanks again.

    Tuesday, September 27, 2011 1:46 AM
  • You're welcome! Your scenario gave me a good reason to clean-up and post code that I've had in my personal toolkit for a long time. I am sure that it will help others in the future and I am happy that it has helped you achieve your goals :)

    Cheers,

    Craig


    Senior Systems Engineer / SharePoint Architect | MSDN Profile
    Microsoft Community Contributor Award 2011 Recipient

    Tuesday, September 27, 2011 1:51 AM
  • Thanks for the post Craig!  I had the same behavior with PDFs after creating a site from a previously saved template that has browser handling set to permissive.  I've been banging my head for a while, and with your post here, I fixed the problem in a couple minutes!
    Friday, December 16, 2011 5:47 PM
  • Please don't use Permissive mode when you can add individual exceptions for file types:

    http://sharepoint.nauplius.net/2011/06/browser-file-handling-and-avoiding.html


    http://sharepoint.nauplius.net
    Friday, December 16, 2011 5:50 PM
  • Craig Lussier ,

    This made my day because I had the exact same situation with the templates. 

    Thanks for that solution. 

    Monday, August 20, 2012 7:07 PM
  • We could open PDF files but they forced a Save/Cancel option when they were attachments in an Announcement list item.  Our farm is set to permissive in both Test and Production; PDF are allowable files types in both farms; I edited the DocIcon.xml file in our Test environment with <Mapping Key="pdf" Value="AdobePDF.png" OpenControl="" /> and this resolved the problem.  I applied it to our Production DocIcon.xml files on all 3 servers with the IISReset and it didn't work.  I even moved the entry to the bottom like it worked for one person.  (SharePoint magic)  Trying to resolve this problem has dragged on for months and all I could find were those options I had already performed.  I am very grateful you offered your knowledge to the rest of us.  Very sincerely, I thank you!
    Wednesday, September 28, 2016 9:03 PM