Monday, June 3, 2013

Enabling PDF previews in your libraries

[Edit: I totally missed http://www.wictorwilen.se/sharepoint-2013-enabling-pdf-previews-in-document-libraries-with-office-web-apps-2013, 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.

13 comments:

  1. Here's how to enable it in your whole farm: http://www.wictorwilen.se/sharepoint-2013-enabling-pdf-previews-in-document-libraries-with-office-web-apps-2013

    ReplyDelete
    Replies
    1. As always, you rock! :) And I missed your post. Added a link to it at the top.

      Delete
  2. I'm trying to use this script but having no luck. At the moment I'm trying to replicate what's in the video above but that is not working at all. Are there extra steps which are not shown in the video I need to take?

    Thanks

    ReplyDelete
    Replies
    1. Hi,
      There's no extra steps besides what's in the video. And remember doing it this way will enable it for this page only. Using Wictor's farm solution and delegate control will enable it all over.

      If you have previews working for Word documents and have installed the March CU for the Office Web Apps server, then this should work.

      What kind of error are you getting?

      Thanks

      Delete
  3. Hi Mikael,
    I've copied the steps in video above, and I'm unable to get the pdf preview to work. (Unfortunately I'm unable to connect to Wictor site)

    I'm attempting to do this in SharePoint online, and don't know if this is why I'm unable to get this to work. Have you tried to get it working on SharePoint Online?

    ReplyDelete
    Replies
    1. Unfortunately PDF previews via Office Web Apps does not work in SPO at the moment. We can only hope MS turns it on at some time.

      Delete
  4. Hi Mikael,
    I am trying to replicated this tutorial. I follow every step and it work while I am on edit mode but once I am done and I hit save the preview functionality stops working.. any idea why?

    ReplyDelete
    Replies
    1. On-premises or online, and you might have client script disabled for users? If on-premises you could use Wictors solution linked at the top.

      Delete
  5. This is not working. I followed video tutotrial and paste this code under script tag

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


    But no luck

    Please assist.

    ReplyDelete
    Replies
    1. Hi,
      What CU do you have of SharePoint 2013? Have you enables the PDF wopi binding with Office web apps (http://www.wictorwilen.se/office-web-apps-2013-patching-your-wac-farm-with-no-downtime)?

      When asking help to troubleshoot you need to let the helper know your setup and environment :)

      Delete
    2. Hi Mikael,

      When I added the script in the Script Editor, PDF Preview is working but at the Top Files & Library[Which we generally used for checking the Librray & Files Settings got invisible]. Can you please let me know how we need to fix that?

      Regards
      Ravi

      Delete
  6. Hi Mikael,

    When I added the script in the Script Editor, PDF Preview is working but at the Top Files & Library[Which we generally used for checking the Librray & Files Settings got invisible]. Can you please let me know how we need to fix that?

    Regards
    Ravi

    ReplyDelete
  7. Hi Ravi, this is an expected behavior if you add any web part to a page contain list web part. You click on the row, it will appear.

    ReplyDelete