This worked on the top level site collection ,but not on doc libs on other site collections in the web application, so I saw within this forum post: http://social.technet.microsoft.com/Forums/en-US/sharepoint2010setup/thread/80365b88-937a-4188-85ef-45cbdc2cd10d that someone suggested the following:
“The http header X-Download-Options: noopen is added by the Browser File Handling and the two setting that are in it. But the Read-only and Edit prompt are driven by SharePoint and a setting in the DOCICON.XML file. If you have added PDF as a Document extension inside the DOCICON.XML you will need to also add an additional attribute in the line and that is opencontrol=”” this seems to stop SharePoint from applying it's header to open the document. <Mapping Key="pdf" Value="icpdf.gif" OpenControl=""/> “
I did this as well but we were still getting prompted. Oddly enough, if you checked out the document, then you could open the PDF directly. Also, NEW doc libraries on these sites would open PDFs correctly. This is all very strange.
I then tried changing the document library setting to force documents to open in the the client application. (Settings > Advanced Settings > Opening Files in the Browser). Still no luck.
At this point, my instinct was that some setting on the document library, that I could not see from the UI, was not getting properly set when I changed the web application level setting.
Well, thanks to Todd Klindt’s blog, http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=214, plus some Powershell wrangling, I was able to find a way to go to the properties of the doc lib and verify that it’s BrowserFileHandling property was still set to “Strict”!
PS C:\ > Add-PSSnapin Microsoft.SharePoint.Powershell
PS C:\> $site = Get-SPSite(“http://mysubsitecollectionurl”)
PS C:\> $web = $site.OpenWeb()
PS C:\> $list = $web.GetList(“http://mysubsitecollectionurl/List”);
PS C:\> $list.browserfilehandling
Strict
No wonder we were still having issues! Using powershell, I was able to set this property to “Permissive”, and my PDFs immediately began opening in Adobe. Whoo hoo!
PS C:\> $list.browserfilehandling = “Permissive” ; $list.update();
PS C:\> $list.browserfilehandling
Permissive
Now I want to be able to go through all my existing doc libs and switch that property. Unfortunately there wasn’t any way to filter out which libraries needed to be switched (manually created ones) and ones that did not (default SharePoint doc libs), so I ended up going through the sites on a case by case basis, mostly driven off the doc lib names b/c we had used site templates to deploy the same doc libs to the different sites.
PS C:> foreach ($list in $rsrWeb.Lists) { if($list.title -match "Documents") { if($list.browserfilehandling -eq "Strict") { $list.browserfilehandling = "Permissive"; $list.update(); $site.url, $list.title, $list.browserfilehandling} } }
Use the line above to copy into your Powershell window, but let me break it out down below:
foreach ($list in $web.Lists)
{
if($list.title -match "Documents") //return any lists with a title containing “Documents”
{
if($list.browserfilehandling -eq "Strict") //if the profile is set to strict
{
$list.browserfilehandling = "Permissive";
$list.update();
$site.url, $list.title, $list.browserfilehandling //print the list url/name for verification
}
}
}
Woo hoo!! Hope this helps you out when dealing with WHY THE HECK is SharePoint hating on PDFs??!!
31 comments:
I am trying our your method on my sites, but I cannot seem to work with any site other than the top-level site in the site collection. This script will not allow me to get into lists within subsites of that site collection to make necessary changes.
Yes, this script is to go on a site by site basis. So if you start out by setting $site = Get-SPSite([Enter your subsite url here]) you should be able to get to your subsite lists.
I did this on a site by site basis b/c my lists were different on different sites. You could probably write a powershell script to recursively go through all the subsites in a site and all the lists in each subsite. I just did not do this b/c I did not need to at the time.
I tried this, but when I got to the last PS command (to show the current browserfilehandling), it didn't give any feedback. Any suggestions?
@The 200 - if you type
$list.Title
do you get anything back? Want to ensure you actually loaded the list.
Thanks for posting this...very informative and helpful.
Thanks for the info, I was banging my head against the wall trying to figure out why I was not in permissive.
Thanks for the information. I was banging my head against the wall trying to figure out why I was not in permissive.
Sharepoint appears to be determined to shred my sanity one point at a time.
Everything in the system says this should work. The admin site says it's set to permissive. The library reports permissive at the PowerShell. And yet it still prompts me to save every single PDF in the library rather than just opening it. I've checked IE's settings, Acroread's settings. Chrome saves the file, Firefox gives you the option to open or save.
I've even tried rebooting the Sharepoint server.
Any thoughts?
Right. Definitely failed a SAN check somewhere there. 3 site collections, guess which one I'd not set to Permissive.
So, note for the future. Even if the library itself reports permissive when you check, that gets over-ridden if you've not set the site collection to permissive.
Aarrgh!
Wow, nice find. Sorry I couldn't help ya before, but thanks for reporting your solution here!
Thanks so much for the help. I have not been able to find where we can set a site collection to Permissive? Can someone help??
Thanks
Hi There,
I set the site collection to permissive, i ran the powershell commands and it says that the library is also permissive.
Still no luck.
Do i have to take some more steps ?
Thanks in advance!
I have read this was fixed in the december sharepoint 2010 cumulative update, can anyone confirm that?
Nice ^-^ this solved my problems
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.
Thanks,
Dmitry
Thanks to this article I was finally able to fix our PDF/SharePoint problem! I changed the script a bit to cover the entire SharePoint site:
$site = get-spsite("https://mysharepointserver.mydomain.local")
foreach ( $subsite in $site.allwebs ) { foreach ($list in $subsite.Lists) { if($list.browserfilehandling -eq "Strict") { $list.browserfile handling = "Permissive"; $list.update(); $site.url, $list.title, $list.browserfilehandling} } }
Receiving this error:
Unexpected token 'handling' in expression or statement.
At line:1 char:148
+ foreach ( $subsite in $site.allwebs ) { foreach ($list in $subsite.Lists) { i
f($list.browserfilehandling -eq "Strict") { $list.browserfile handling <<<< =
"Permissive"; $list.update(); $site.url, $list.title, $list.browserfilehandling
} } }
+ CategoryInfo : ParserError: (handling:String) [], ParentContain
sErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
@George - where you have "$list.browserfile handling"
it should be
"$list.browserfilehandling"
Found it 10 minutes after posting.
THANKS!
Hope this helps everyone out too. This is not necessarily a solution to this problem alone but the settings below have an impact on the way the browser handles files.
Anyone that's enabled PDF integration with SharePoint will probably have found themselves adding "PDF" as an extension to this file:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML\DOCICON.XML
Something like this I imagine:
Mapping Key="pdf" Value="icpdf.gif"
(opening and closing chevron brackets removed for this blog entry)
Well here's the rub. This Mapping tag can also include an OpenControl tag.
e.g.:
Mapping Key="docx" Value="icdocx.png" EditText="Microsoft Word" OpenControl="SharePoint.OpenDocuments"
or
Mapping Key="css" Value="iccss.gif" OpenControl=""
Now, if the OpenControl tag is missing completely, the browser will prompt you to open/save the document!
So, changing the PDF entry to:
Mapping Key="pdf" Value="icpdf.gif" OpenControl=""
has fixed my problem.
I had already run the scripts on here, so as I say, this is perhaps part of the problem at least, however, I was having exactly the same problem with JPG and PNG files, and adding this tag in has resolved that problem as far as I can tell.
Hope that helps
Chris
Thanks for sharing Chris!
Thanks Cookie it's a great post !
Worked! Thanks!
Worked! Thanks!
Just a note from the MSDN Documentation regarding the BrowserFileHandling:
--
This is a list-level override of site settings in BrowserFileHandling. If this setting is BrowserFileHandling.Strict then files inside this list are handled in a strict fashion even if the SPWebApplication setting is BrowserFileHandling.Permissive. However if the site setting (in SPWebApplication.BrowserFileHandling) is BrowserFileHandling.Strict then this (the list) setting is ignored.
--
To summarize; If the setting is set to Strict in the Web Application, you can't change it to Permissive in the list instance.
Thanks ! After banging my head against the wall and the desk and having my coworkers rejoicing with my swearing - your PS did the trick. Perfect. Thumbs up !!!!
Hi,
I have a pdf form and I want people to fill up the form and want to publish the contents of the form onto the Sharepoint site. I have uploaded the form on the Sharepoint.
So what do I have to do so that I get the contents displayed onto the sharepoint site?
Thanks.
Rishi
Awesome! Just ran into this problem and wasn't sure how to change that setting for the subsites. Ran the script and it worked like a charm.
Thank you - I too am going on a Sharepoint journey, and am amzad at the number of little details that need to be mastered. This was one of them - drove me batty for a while.
Thanks! Solved my problem beautifully!
Thanks! Solved my problem easily!
Post a Comment