Sunday, January 16, 2011

Missing the open button when opening PDF files from SharePoint 2010.

By the default setting of a SharePoint 2010, a users can’t open PDF files and many other files types (see the bottom of the post for all default file type allowed to download http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.allowedinlinedownloadedmimetypes.aspx) direct from SharePoint, neither “Display PDF in browser” mode or in the download popup, where the “open” button is missing.
clip_image001

The thing is SharePoint 2010 adds an additional security header to force the file to be saved to the disk before the users can open it. To fix this the BrowserFileHandling property should be set to “permissive” http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbrowserfilehandling.aspx. This property exist both on a webapplication level http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.browserfilehandling.aspx and a on document library level http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splist.browserfilehandling.aspx.

To fix this on a webapplication level, by using the GUI.

  1. Open Central Administration
  2. Application Management
  3. Manage Web Applications
  4. Select the webapplication to change
  5. Click General Settings in the ribbon
  6. Scroll down to Browser File Handling and select Permissive
  7. Click on the OK button

clip_image003

To fix this with PowerShell on a webapplication level

Get-SPWebApplication http://vsitsp01 | % { $_.BrowserFileHandling = "permissive"; $_.update() }

To fix this with PowerShell on a document library level

$spweb = Get-spweb http://vsitsp01

$doclib = $spweb.Lists["Documents"]

$doclib.BrowserFileHandling

$doclib.BrowserFileHandling = "permissive"

$doclib.Update()

File types allowed to be download:

application/directx
application/envoy
application/fractals
application/internet-property-stream
application/liquidmotion
application/mac-binhex40
application/ms-infopath.xml
application/msaccess
application/msword
application/oda
application/oleobject
application/onenote
application/pics-rules
application/pkcs10
application/pkcs7-mime
application/pkcs7-signature
application/pkix-crl
application/postscript
application/rtf
application/set-payment-initiation
application/set-registration-initiation
application/streamingmedia
application/vnd.fdf
application/vnd.ms-excel
application/vnd.ms-excel.12
application/vnd.ms-excel.addin.12
application/vnd.ms-excel.binary.12
application/vnd.ms-excel.macroEnabled.12
application/vnd.ms-excel.macroEnabledTemplate.12
application/vnd.ms-excel.template.12
application/vnd.ms-office.calx
application/vnd.ms-officetheme
application/vnd.ms-pki.certstore
application/vnd.ms-pki.pko
application/vnd.ms-pki.seccat
application/vnd.ms-pki.stl
application/vnd.ms-powerpoint
application/vnd.ms-powerpoint.12
application/vnd.ms-powerpoint.addin.12
application/vnd.ms-powerpoint.macroEnabled.12
application/vnd.ms-powerpoint.presentation.12
application/vnd.ms-powerpoint.show.12
application/vnd.ms-powerpoint.show.macroEnabled.12
application/vnd.ms-powerpoint.slide.macroEnabled.12
application/vnd.ms-powerpoint.template.12
application/vnd.ms-powerpoint.template.macroEnabled.12
application/vnd.ms-project
application/vnd.ms-visio.viewer
application/vnd.ms-word.document.12
application/vnd.ms-word.document.macroEnabled.12
application/vnd.ms-word.template.12
application/vnd.ms-word.template.macroEnabled.12
application/vnd.ms-works
application/vnd.ms-xpsdocument
application/vnd.oasis.opendocument.presentation
application/vnd.oasis.opendocument.spreadsheet
application/vnd.oasis.opendocument.text
application/vnd.openxmlformats-officedocument.presentationml.slide
application/vnd.rn-realmedia
application/vnd.visio
application/vnd.visio.webdrawing
application/winhlp
application/x-bcpio
application/x-compress
application/x-cpio
application/x-csh
application/x-dvi
application/x-gtar
application/x-gzip
application/x-hdf
application/x-internet-signup
application/x-iphone
application/x-latex
application/x-miva-compiled
application/x-ms-application
application/x-ms-manifest
application/x-ms-reader
application/x-ms-vsto
application/x-ms-wmd
application/x-ms-wmz
application/x-msaccess
application/x-mscardfile
application/x-msclip
application/x-msdownload
application/x-msmediaview
application/x-msmetafile
application/x-msmoney
application/x-mspublisher
application/x-msschedule
application/x-msterminal
application/x-mswrite
application/x-netcdf
application/x-oleobject
application/x-perfmon
application/x-pkcs12
application/x-pkcs7-certificates
application/x-pkcs7-certreqresp
application/x-sh
application/x-shar
application/x-smaf
application/x-stuffit
application/x-sv4cpio
application/x-sv4crc
application/x-tar
application/x-tcl
application/x-tex
application/x-texinfo
application/x-troff
application/x-troff-man
application/x-troff-me
application/x-troff-ms
application/x-ustar
application/x-wais-source
application/x-x509-ca-cert
audio/aiff
audio/basic
audio/mid
audio/mpeg
audio/wav
audio/x-aiff
audio/x-mpegurl
audio/x-ms-wax
audio/x-ms-wma
audio/x-pn-realaudio
audio/x-pn-realaudio-plugin
audio/x-smd
drawing/x-dwf
image/bmp
image/cis-cod
image/gif
image/ief
image/jpeg
image/pjpeg
image/png
image/tiff
image/vnd.wap.wbmp
image/x-cmu-raster
image/x-cmx
image/x-icon
image/x-jg
image/x-portable-anymap
image/x-portable-bitmap
image/x-portable-graymap
image/x-portable-pixmap
image/x-rgb
image/x-xbitmap
image/x-xpixmap
image/x-xwindowdump
text/calendar
text/css
text/dlm
text/h323
text/iuls
text/plain
text/richtext
text/setext
text/tab-separated-values
text/x-ms-iqy
text/x-setext
text/x-vcard
video/mpeg
video/quicktime
video/x-ivf
video/x-la-asf
video/x-ms-wm
video/x-ms-wmp
video/x-ms-wmv
video/x-ms-wmx
video/x-ms-wvx
video/x-msvideo
video/x-sgi-movie

5 comments:

  1. The above solution doesn't show the open, save & cancel dialog. It directly opens the PDF in browser.

    ReplyDelete
  2. I think you need to also make an entry in the DOCICon.xml file like:


    Be sure to add the png file to the images directory.

    ReplyDelete
    Replies
    1. Hi KansasCoder
      Thank you for the comment. No you don't. You need to change the DOCIcon.xml to display the PDF icon. (in SP2013 is there out-of-the-box)

      Delete
  3. Hi Admin,
    Excellent blog and its totally loaded with valid posts on Java and .Net technology. Consider including RSS feed in your blog, so aspirants like me can follow your blog easily. Dot Net Training in Chennai

    ReplyDelete
  4. I like your writing style, it was very clear to understanding the concept well; I hope you ll keep your blog as updated.
    Regards, SAS Course in Chennai

    ReplyDelete