SharePoint中默认打开PDF(不下载)

在SharePoint2010中,需要在浏览器中默认打开PDF,而不需要下载下来再打开。客户端已经安装有PDF插件。

1. 在SharePoint2010管理中心-应用程序设置-常规处理-浏览器文件处理程序(BrowserFileHandling),设置为许可(Permissive),不添加标头,允许非office文档能够直接打开。

    结果在首站点没问题,有些子站点仍然只能下载。

2. 在首页网站集功能中,关闭“默认情况下,在客户端应用程序中打开文档” 

    设置完后,仍然不能在浏览器中打开,跟踪发现,以下标头仍然存在,正常的没有以下标头

    Content-Disposition:attachment; filename=XXXXX.PDF

    X-Download-Options:noopen

  

于是在http://www.pdfsharepoint.com/sharepoint-2010-and-pdf-integration-series-part-1/找到了终极解决方案,上述设置都无需改变

1 $webApp = Get-SPWebApplication http://localhost
2 If ($webApp.AllowedInlineDownloadedMimeTypes -notcontains "application/pdf")
3 {
4 Write-Host -ForegroundColor White "Adding Pdf MIME Type..."
5 $webApp.AllowedInlineDownloadedMimeTypes.Add("application/pdf")
6 $webApp.Update()
7 Write-Host -ForegroundColor White "Added and saved."
8 } Else {
9 Write-Host -ForegroundColor White "Pdf MIME type is already added."
10 }

后记:

MSDN 中描述:This property is ignored when the BrowserFileHandling property is set to Permissive

应用程序的BrowserFileHandling设置为Permissive后,将忽视AllowedInlineDownloadedMimeTypes该属性设置,

而我的测试结果确不是这样,不知道是不是SharePoint2010有BUG,刚刚打过SP1 :D。

 

 

posted @ 2012-04-28 17:08  老万 - 一刀  阅读(1290)  评论(0编辑  收藏  举报