Document Preview in SharePoint Document Library 2010

There have been many instances where we need to show the document preview in the document library just to give the look and feel of the document uploaded in the SharePoint Library.
In this blog, I will detail out the list of the steps to achieve the functionality using Server Side code or Server object Model.
 
Before implementing this piece of code, we need to add a picture column in the document library. The below code overrides the existing ItemAttachmentAdded event.
  1.  public override void ItemAttachmentAdded(SPItemEventProperties properties)  
  2.  {  
  3.      base.ItemAttachmentAdded(properties);  
  4.   
  5.      SPListItem item = properties.ListItem;  
  6.      //SPAttachmentCollection attach = item.Attachments;  
  7.      string attachmentUrl = item.Attachments.UrlPrefix + item.Attachments[0];  
  8.   
  9.      item["PicturePreview"] = attachmentUrl;  
  10.      item.Update();  
  11. }  
 Happy SharePointing :-)