SharePoint 2020

The Vision for a Future of Clarity

Add a PDF Thumbnail Hover Preview Column to a Document Library

I got this request from Jewell from my previous post:

Display PDF Thumbnail Preview on Hover in Search Results Web Part

“Is there away to apply this to a document library?”

Here are the steps to add a pic of a magnifying glass to a column in a Document Library.

So that when your mouse hovers, it displays the first page of the PDF inside an iFrame window.

The only down-side to having this implemented, is that as the user hovers over each PDF, it needs to download the entire PDF file to display the first page.
 

* Document Library with the PDF Preview column added

pdfs - All Documents

* On Mouse-Over

pdfs preview

Step 1: First you’ll need to create a workflow that copies the Document Name to the Title column.

Follow this post to do exactly that: http://www.knowledgegroup.no/blogg/post/2012/05/13/Add-filename-in-title-field-using-workflow.aspx

Step 2: Go to http://cssglobe.com/easiest-tooltip-and-image-preview-using-jquery/ and download the Scripts Zip file.

You’ll need the 3rd Example files uploaded to a Document Library to hold your script files.

Step 3: Open up main.js and replace the text with this modified version: PDF thumbnail script .docx or the pastebin version: http://pastebin.com/Gb5mGw1c

Step 4:  Create a html file in the same folder as your scripts and paste the following:

Don’t forget to change the paths to your script files.

<script src="/server/site/scripts/jquery.js" type="text/javascript" ></script>
 <script src="/server/site/scripts/main.js" type="text/javascript"></script>
 <style>
 #screenshot{
 position:absolute;
 border:1px solid #ccc;
 background:#333;
 padding:5px;
 display:none;
 color:#fff;
 }
 </style>
Step 5:
Add the HTML file to the source of a Content Editor Web Part in the document library that holds the PDF files.
Step 6: Add a Calculated Column in the Document Library, call it Preview and select type returned as:
Number (1,2,3…).
Add the following from here:
http://pastebin.com/XgQA85m7
or from here:
="<DIV><a href='..\"&Title&".pdf' class='screenshot' rel='..\"&Title&".pdf' ><img border='0' src='/_layouts/images/MAGNIFY.GIF' alt='' style='padding-right: 5px; padding-left: 5px; vertical-align:bottom'></a></DIV>"
That’s it! Now hover over the magnifying glass image and you should see the PDF thumbnail display.
Any questions or comments, post it below. Thanks for reading.
Advertisements

November 4, 2013 Posted by | SharePoint 2010, SharePoint Designer 2010 | , | 12 Comments