SharePoint 2013: Enabling PDF Previews with Office Web Apps 2013 March 2013 update

Tags: SharePoint 2013, Office Web Apps

In my last post (still smoking fresh) I showed you how to update your Office Web Apps 2013 farm to the March 2013 update, connect it to SharePoint 2013 and being able to view PDF documents in the browser. What I didn’t explain or show in that post was how to enable the PDF Previews in Search – but I’ll do it now.

Pre-requisites

Before you start fiddling with this, you need to make sure that you have the March 2013 update of Office Web Apps Server 2013 (WAC) installed and connected to your farm – if you don’t know for sure, ask your admins – sometimes they know…if they don’t give them the link to my previous blog post.

Note: You don’t have to have a patched SharePoint 2013, this will work on the RTM bits.

Default PDF Search Experience

SharePoint 2013 natively supports crawling PDF documents, through the new document parsers. That is you don’t have to fiddle with any custom PDF IFilters etc. The native PDF document parser is a good enough solution, but have some room for improvements.

The Search Experience and display in SharePoint 2013 is based upon Display Templates. Display Templates decide how the result should be shown and how the fly-out of the result should look like. For Office documents, when SharePoint 2013 is connected to a WAC farm, SharePoint displays inline previews which you can use to skim through the results really quick. For PDF this is not the case – not even if you use a WAC farm with the March 2013 update (even though the WOPI binding supports the interactivepreview action). This is a sample on how a PDF document could look like in SharePoint 2013 Search:

Default PDF Search Experience

Enabling PDF Previews in the Search Result

Since we have the opportunity to modify the Display Templates and create our own Search Experience we can very easy modify the fly-out/hover panel of the PDF results to show the interactive preview. We can do this in two different ways…

Create a new Result Type

The easiest and fastest approach to enable our previews for PDF documents is by creating a custom Result Type. This is done by going to Site Settings > (Search) Result Types and then finding the PDF Result Type. Choose to Copy the Word Result Type. This will create a new Result Type.

Copy the Result Type

Give the new Result Type an appropriate name, “PDF with Preview” for instance. Then scroll down to Actions and in the “What should these results look like?” drop-down, choose to use the Word Display Template.

Word or PDF?

Then just click Save, go back to your Search Center and search for a PDF document and voilá – we have PDF Previews.

PDF Previews in da house!

Modifying the PDF Display Templates

The second approach, which is a bit more advanced is to actually modify the PDF Flyout Design Template. You do this by going to Site Settings > Design Manager then choose 5. Edit Display Templates. Locate the PDF Flyout item by filtering on the Target Control Type column and use SearchHoverPanel, then scroll down to PDF Hover Panel. To modify the PDF Hover Panel, use the Word Hover Panel as a template. I’m not going in to all the details on how to modify the actual HTML file (see my similar post on how to achieve this here). But once you’ve modified it, make sure to save it to the gallery so the JS file is generated, and publish it. Now (if you made the correct updates) you will have Custom Search Previews for PDF documents.

Summary

You’ve now seen how you quick and easy can enable PDF Search Previews in SharePoint 2013 using the March 2013 update for Office Web Apps 2013. All you need to do is either create a custom Result Type and use the Word Display Templates or modify the default PDF Display Template. I really hope that Microsoft makes this a standard feature for upcoming SharePoint 2013 releases.

No Comments

  • Benjamin said

    Great write up, also this was covered on TechNet with the Display Template available for download a while back if some want to download it:

    http://blogs.technet.com/b/speschka/archive/2012/12/20/create-an-easy-pdf-preview-for-search-results-in-sharepoint-2013.aspx

  • Wictor said

    @Benjamin - there's a huge difference in Steves method versus this one. Steve uses client rendering - requiring you to have Craprobat Reader or similar installed, and in this case it's server side rendering using WAC. Rendering it client side has huge implications on security - you know that PDF actually stands for Potentially Dangerous Files.

  • Jim said

    Excellent information! I was able to get the PDFs to view with WAC, but after following your instructions, I don't get the PDF preview in the search. I am getting the correct display template because it shows the type as Word item in the display template, but there's no box for preview. As I mentioned, it works properly if I open a PDF from a doc library, just not preview in search. Help?

  • Chris said

    Hi,
    I have same issue.

    says "Microsoft Word" but does not preview even after a full crawl.

    Does SharePoint have to be patched to March as well?

  • Mike said

    Nice post on the search feature. What I really want to see is how to display a hover panel preview for PDF's in a library just like Office Web Apps. Any ideas?

  • PeterGa said

    @Mike : Here is page, where the guy wrotes that it is working.
    http://blog.hametbenoit.info/Lists/Posts/Post.aspx?ID=499#.UWvSkUrLvh2

    But I do not know, I read only about PDF Search Preview.

    Any experiences with OWA and PDF Preview from Document Library?

  • Corey Roth said

    Although, I can use the view in browser functionality in a document library, I did not get the technique using the word display template to work. Maybe I'll try customizing the display template instead.

    Corey

  • Sorin said

    Tried this on an On-Premises farm and after a Full Crawl it's working
    But on a Office 365 site it's not working.
    Any ideas when it's done a full crawl on a Office 365 site ?

  • Erucy said

    Great post! I updated my server successfully, but I also found a problem: when I use my phone to view the document, it said "viewing .pdf file is disabled of microsoft word mobile viewer" (I can view the same document in normal view). Does it means WAC is not support pdf file in mobile view for now?

  • Markus said

    Works great. But -
    is it possibly only working for pdf's in the same web application as the search results page? Pointing at a search result residing in a different web app shows the preview page with the document title and a text saying "To start seeing previews, please log on by <opening the document>". Of course I can use that separate web app's sites without additional logon, I can open the document from search result pane, it still shows that message.
    Any proposals are really welcome.

  • ines said

    Ok, the error has not to do with the solution but with the word preview, it seems documents with accents in title throw erros when previewed

  • Daniel said

    Hi

    I added the Result Type in my main site. After a full crawl my Web Apps Viewer kicks in for a pdf in a doc a library. However, I am getting

    Microsoft Word Web App

    Sorry there is a problem and we can't open this pdf. If this happens again , try opening the pdf in Microsoft Word"

    When I do that in word 2013 the doc is converted no problems.

  • Michael Kammerer said

    Hi Wictor,
    Did you also recognize, that the rendering quality of pdf is very poor? We upload word and pdf documents. Word documents are more or less ok. PDF documents are rendered in such a poor quality, that you can not read tables, graphs,... ... everything is completely blured.
    Do you have any work a round?
    Thanks Michael

Comments have been disabled for this content.

AWS Tracker

About Wictor...

Wictor Wilén is a Director and SharePoint Architect working at Connecta AB. Wictor has achieved the Microsoft Certified Architect (MCA) - SharePoint 2010, Microsoft Certified Solutions Master (MCSM) - SharePoint  and Microsoft Certified Master (MCM) - SharePoint 2010 certifications. He has also been awarded Microsoft Most Valuable Professional (MVP) for four consecutive years.

And a word from our sponsors...

SharePoint 2010 Web Parts in Action