Partager via


SharePoint: Adding icons for other document types (like PDF)

I've seen lots of questions on various SharePoint newsgroups about how to get PDF files to show up with the right icon in document libraries. The process is documented in the WSS admin guide, but it's not that easy to find. I'm working with the folks in PSS/Product Team to try to get a KB article on this topic. In the meantime, though, here it is:

At a high level, all you need to do is get the icon into the \template\images directory, and then map the extension to the icon in \template\xml\docicon.xml. Then you reset IIS, and voilà, you have your mapping.

So, let's say you've already dropped icpdf.gif into the \template\images directory. You would then modify docicon.xml to add the mapping that points to the icon (in bold below):

 <DocIcons>
  <ByProgID>
    <Mapping Key="Excel.Sheet" Value="ichtmxls.gif"/>
    <Mapping Key="PowerPoint.Slide" Value="ichtmppt.gif"/>
    <Mapping Key="Word.Document" Value="ichtmdoc.gif"/>
  </ByProgID>
  <ByExtension>
    <Mapping Key="doc" Value="icdoc.gif"/>
    <Mapping Key="gif" Value="icgif.gif"/>
    <Mapping Key="htm" Value="ichtm.gif"/>
    <Mapping Key="html" Value="ichtm.gif"/>
    <Mapping Key="ppt" Value="icppt.gif"/>
     <Mapping Key="pdf" Value="icpdf.gif"/> 
  </ByExtension>
</DocIcons>

Now, let's say you also want to add a new default icon for unknown file types, called icunk.gif. Again, you'd drop the icon in the \template\images directory, but this time you'd modify docicon.xml to add a default value that is used if a matching can't be made by ProgID or Extension (in bold below):

<DocIcons>
<ByProgID>
<Mapping Key="Excel.Sheet" Value="ichtmxls.gif"/>
<Mapping Key="PowerPoint.Slide" Value="ichtmppt.gif"/>
<Mapping Key="Word.Document" Value="ichtmdoc.gif"/>
</ByProgID>
<ByExtension>
<Mapping Key="doc" Value="icdoc.gif"/>
<Mapping Key="gif" Value="icgif.gif"/>
<Mapping Key="htm" Value="ichtm.gif"/>
<Mapping Key="html" Value="ichtm.gif"/>
<Mapping Key="ppt" Value="icppt.gif"/>
<Mapping Key="pdf" Value="icpdf.gif"/>
</ByExtension>
<Default>
<Mapping Value="icunk.gif"/>
</Default>

</DocIcons>

Happy mapping, and don't forget to restart IIS when you're done!

1/21 1:25 pm pst: Updated to fix broken link in first paragraph and formatting issues (aarg!)

Comments