Resolving SharePoint 2010 PDF Issues with PowerShell

PDF’s that have been uploaded to your SharePoint 2010 document libraries do not show the correct icon and only give you the option of saving instead of opening them:

The following PowerShell script downloads a 17×17 GIF image from Adobe.com named pdficon_small.gif, places it in the images folder under the 14 hive, associates it in the DOCICON.XML file, sets Browser File Handling to Permissive, and then runs IISReset:

 

The first part of the script downloads a pdf icon from Adobe.com to the Images folder:

The second part associates PDF’s in SharePoint with this PDF GIF image icon file:

The third portion of the script sets the Browser File Handling to Permissive so that the PDF’s are able to be opened instead of only saved. This was implemented on an Intranet SharePoint server so I consider this decrease in security to be an acceptable risk:

The last thing it does is run IISReset:

PDF’s now have the correct icon and are allowed to be opened:

The PDF icon issue and information about associating it in SharePoint is documented in this Microsoft KB Article.

µ

2 Comments

  1. Oliver Van Camp (@olivervancamp)

    Mike,

    A more elegant (and secure) way to enable opening PDF files is by adding the pdf extension to the allowed MIME types of the web application:

    $webapp = Get-SPWebApplication
    $webapp.AllowedInlineDownloadedMimeTypes.Add(“application/pdf”)
    $webapp.Update()

    Great script, btw: one for the SP Admin toolbox!!

    Oliver

    (Reference: https://www.nothingbutsharepoint.com/sites/devwiki/articles/Pages/SharePoint-2010-PDF-files-can-not-be-opened-directly-only-saved.aspx)

    Reply

Leave a Reply

%d bloggers like this: