Tuesday, January 29, 2013

Add PDF Icon to SharePoint Library

We come across many occasions where PDF files are uploaded to SharePoint 2007/2010 Libraries or Lists. 

While we can easily see the images of our regular Word, Excel, PowerPoint documents, however the PDF documents look empty without the trademarked image.

Well, no problem, who says we can't have it. It is fairly simple, so let us see how:
  • Get the appropriate Adobe PDF icon image (preferrably a gif) from here 
  • Save that image confirming with SharePoint images standard such as icopdf.gif. Place the image where Office document icons exist by-default. Check out this 12 Hive path of your MOSS 2007 or 14 Hive path of your Sharepoint 2010 installation:
    Drive\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Images
      Drive\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Images
  • Now that we have successfully placed the image, we need to inform SharePoint about our modification. For doing this, we need to add an entry to the DocIcon.xml file which sits in theDrive\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12 or 14\Template\Xmlpath
  • Open the docicon.xml with any editor such as Visual Studio or even Notepad. Under ByExtensionsection, add a key/value pair as given below:
    Mapping Key="pdf" value="icopdf.gif"
    Note
    Take a backup copy of the DocIcon.xml prior to the changes (to be on the safe side). Also, the XML start-end tags are removed as the post wouldnt allow it easily. Kindly take care in your case.
  • Save changes to Docicon.xml file. Perform an IISRESET command to finalize the same.
Refresh & check the same list or library page to notice the changes take effect.
Briefly, what this does has done is, if SharePoint sees any file (new/old) with an extension .pdf, it would display the PDF icon against the file as it does for Office documents. 

No comments:

Post a Comment