Monday, June 3, 2013

Enabling PDF previews in your libraries

[Edit: I totally missed, so this post is almost a dupe - sorry about that]

You installed the March CU for Office Web Apps 2013 (WAC) which supports rendering PDF files, and followed Wictor Wilén’s post on how to enable PDF previews for your search results (and perhaps his post on installing the CU as well).

Then you read the comments and saw that others like yourself want to get these PDF previews for document libraries and not only on the search result page.
Want to know how? Read on!
Enabling PDF preview in a SharePoint Library

File previews in SharePoint 2013 are handled by the script filepreview.js, and this script has not yet been updated to handle PDF files. You could either edit the file manually, which we know we should stay clear of, or add the following script snippet somewhere to be loaded on your page.

SP.SOD.executeFunc('filePreview.js', null, function () {
    embeddedWACPreview.dimensions["pdf"] = embeddedWACPreview.dimensions["docx"] ;
    filePreviewManager.previewers.extensionToPreviewerMap["pdf"] = filePreviewManager.previewers.extensionToPreviewerMap["docx"] ;
} );

What the script does is copy the registrations for Word document previews, and attaching it to the PDF file extension. Good places to add this would be your master page, a script file always included on all pages or similar.