Archives

Archives / 2013 / April
  • SharePoint 2013: Enabling PDF Previews in Document Libraries with Office Web Apps 2013

    Tags: SharePoint 2013, Office Web Apps

    Introduction

    A couple of weeks back I blogged about the March Update for Office Web Apps 2013 and also how you could use that update to show PDF previews in a SharePoint 2013 Search Center. Since then I’ve received a lot of requests on how to enable PDF Previews in a Document Library, which isn’t there by default. Of course it is not a WAC thing, it’s a SharePoint 2013 thing – but the SharePoint 2013 updates (up until now at least) does not provide this capability either.

    In this post I will show you that it can be done. It’s a JavaScript thing and can be done using a Content Editor Web Part added on all pages where you want the PDF previews or as Farm solution which uses a delegate control and a custom JavaScript file.

    [Update 2014-01-01] Some customers may see errors when using this solution and previewing PDFs. If so, make sure that you have the http://support.microsoft.com/kb/2825665 hotfix installed. Thanks to Dan from MSFT Support.

    Build the PDF Preview solutionhe

    I assume that you are familiar with SharePoint 2013 development and knows what a delegate control is. What you need to do is create a new empty Farm solution project. In this project we’ll create a new web control that will add a JavaScript (which we will create in just a minute) to the page. The implementation should look like below:

    [MdsCompliant(true)]
    public class PdfPreviewControl: WebControl
    {
        protected override void OnPreRender(EventArgs e)
        {
            ScriptLink.RegisterScriptAfterUI(this.Page, "wictor.pdfpreviews/previews.js", false);
        }
    }

    The JavaScript file, added as a Layouts file, is what makes the magic happen. We’re using the Script-On-Demand features in this script to make sure that the scripts aren’t executed before the SharePoint filepreview.js file is loaded. Once that file is loaded two new JavaScript objects are created; the filePreviewManager and the embeddedWACPreview. To enable the PDF previews we only need to add the PDF extension to these objects and specify the previewer objects and the dimensions. In this case I use the same settings as the other Word previewers.

    function WictorsPdfPreviews() {
        SP.SOD.executeOrDelayUntilScriptLoaded(function () {
            filePreviewManager.previewers.extensionToPreviewerMap.pdf = 
                [embeddedWACPreview, WACImagePreview];
            embeddedWACPreview.dimensions.pdf= { width: 379, height: 252}
        }, "filepreview.js");
        notifyScriptsLoadedAndExecuteWaitingJobs("wictor.pdfpreviews/previews.js");
    }
    WictorsPdfPreviews();

    Now we need to make sure that this control loads the JavaScript on all pages. This is done by adding a new Empty Element SPI and creating a Control element pointing to the web control, like this:

    <Control 
      ControlAssembly="$SharePoint.Project.AssemblyFullName$" 
      ControlClass="Wictor.PdfPreviews.PdfPreviewControl" 
      Id="AdditionalPageHead" 
      Sequence="100"/>

    As you can see we’re adding this control to the AdditionalPageHead, which means that we will have it on every page. Do not forget to add the web control as a Safe Control in the project!

    The final thing we need to do is to modify the Feature that was automatically created when the Empty Element SPI was added to the project. You can scope it to whatever you like, but I want it for all Document Libraries in my farm so I set the scope to Farm. The image below shows all the files in the project.

    The Visual Studio 2012 solution

    Deploy and Test

    Now all we have to do is to deploy the solution. Once the solution is deployed and the Farm feature activated we can navigate to any document library and upload a PDF file. Note that you have to be on at least the March 2013 update of Office Web Apps Server and that you have enabled the WordPDF application (see previous blog post). Once you have the PDF file in the library you can click on the ellipsis button and see the PDF Preview:

    PDF Previews in SharePoint 2013

    Disclaimer

    As always when it comes to stuff that is not documented. I do not give any guarantee that this will work on your machine(s) or after any upcoming SharePoint patches.

    Summary

    Enabling PDF Previews are not (yet) a default feature of SharePoint 2013 but can easily be added to your SharePoint farm – if you’re allowed to use Full Trust solutions.  If you don’t feel like you want to do some hacking yourself you can download the WSP here and deploy it yourself to try it out.

  • Recertified as Microsoft Certified Solutions Master (MCSM) for SharePoint

    Tags: MCSM, SharePoint, SharePoint 2013

    Yesterday I got the really cool news that I completed all recertification requirements for the Microsoft Certified Solutions Master: SharePoint certification. Couldn’t be a happier SharePoint professional right now!

    MCSM: SharePoint

    What is the MCSM and what about MCM?

    The Microsoft Certified Master (MCM) program has during the latest year transitioned into the Microsoft Certified Solutions Master (MCSM) program. It is not only a change in name but also a change made to adapt to the new world order. The program is not longer focusing on one specific version of the product but instead focus on what’s in the market at the current moment and specifically it covers both on-premise and cloud solutions. This is good in many senses – this allows the program to always be current, always use the latest techniques and technologies etc. The MCM was a certification without expiration date (well eventually the product cease to exist, but you still have the cert) whereas the MCSM has a three year life span and you must recertify to stay on top.

    The first MCSM : SharePoint rotation!

    I was fortunate to be able to participate in the rotation called U3, or Upgrade 3, which was the first MCSM rotation for SharePoint. It was two weeks on site, in the always sunny and warm Seattle, in January. I had the opportunity to spend these two weeks in a class room with the finest SharePoint professionals there is. We had great instructors, awesome labs, and fantastic discussions over the two weeks duration. It all led up to one written exam, called the Knowledge Exam, and one hands on lab, called the Qualification Lab. As always the QL was basically doing a couple of weeks worth of deep dive SharePoint work in about 8 hours time. Taken into account that this was a beta it was just about the hardest work I’ve ever done – but it was pure fun. And I made it! Phew…

    Congrats to all my other friends that made it through this rotation and best of luck to the ones who will have the joy of doing the exams one more time! You can do it!

  • Introducing Open WOPI - an open WOPI Client for SharePoint, Exchange and Lync

    Tags: SharePoint 2013, WOPI, Office Web Apps, Open WOPI

    Today at the SharePoint Evolutions 2013 Conference I announced my latest pet project called Open WOPI. Open WOPI is an open WOPI client that allows you to extend SharePoint 2013, Exchange 2013 and Lync 2013 with file previews and editors for any type of file formats.

    Open WOPI

    The project is now (at least very, very soon) available to download from openwopi.codeplex.com and is published under the Ms-PL license. This is currently an early beta (or what you would like to call it) but will be improved over time.

    Standards

    Open WOPI is based on the [MS-WOP] protocol, published by Microsoft, and used by Office Web Apps Server 2013, SharePoint 2013, Exchange 2013 and Lync 2013.

    File format support

    Currently Open WOPI has support for the following formats:

      • GPX - Uses Bing maps
      • TXT - Viewing and editing
      • VSDX - Thumbnail viewing

    More formats are in the works…

    Documentation

    Not much yet, but I’ll try to add that over the next few weeks.

    More information

    For more information, feedback and ideas about the project please refer to the Codeplex site: openwopi.codeplex.com. I’d like to hear what file formats you would like Open WOPI to support.

    The slides from the presentation at the SharePoint Evolutions conference and links can be found here.

    Contributors

    Thanks to Sam Dolan, aka Pinkpetrol, for the really cool logo for Open WOPI.

  • SharePoint 2013: Enabling cross domain profile pictures

    Tags: SharePoint 2013

    Just discovered a really interesting and just awesome nugget in SharePoint 2013 that solves a problem that have been annoying me for a long time. The problem manifests itself when you’re having multiple URL’s for your SharePoint farm or when using SAML or Forms based login (like in Office 365 and SharePoint Online) and you’re using the profile pictures on sites not residing on the My Site Host Web Application (or host named site collection). Then the user profile picture is not shown, you get the default image not found image or you’re prompted to authenticate with the My Site Host.

    Let’s take an example. Assume I have one site at intranet.contoso.com and the My Site host exists on mysite.contoso.com. I have not configured any Internet Explorer zones or anything and I’m promted to log in at each location. This is how the Newsfeed Web Part will look like on intranet.contoso.com, if I cancel out the authentication prompt or if I’m using some forms based login:
    No picture...

    You see, no fancy picture of Mr administrator! There’s a couple of ways to solve this using IE Zones, anonymous access etc, but none are perfect and comes with consequences.

    So how can I get the picture to be shown without messing with security, cross domain issues etc. Fortunately I guess I was not the only one that was annoyed by this (most likely everyone using Office 365 as well) so the SharePoint team has added a new feature to SharePoint that allows us to show profile pictures cross-domain.

    It’s a very simple operation and just requires some basic PowerShell skills. Basically all you need to do is to set the CrossDomainPhotosEnabled property on the SPWebApplication object to true, like this:

    asnp Microsoft.SharePoint.PowerShell
    $wa = Get-SPWebApplication http://intranet.contoso.com
    $wa.CrossDomainPhotosEnabled = $true
    $wa.Update()

    Now the Newsfeed, in the sample above, will look like below. And I was not prompted for any authentication or anything! Isn’t that sweet! And it works very well on Host Named Site Collections as well.

    Look at that guy!

    Basically what happens behind the scenes is that the request for the user picture is sent via a “proxy” .aspx page called userphoto.aspx which takes a couple of parameters; URL of the picture, the account name (or e-mail) as well as the picture size (S, M or L). This page will return a JPEG stream of the user profile picture without crossing any domains on the client side.

    I hope this little nugget will save you and your customers a lot of time and annoyance..

  • SharePoint 2010 Web Parts in Action as the Manning Deal of the Day

    Tags: SharePoint 2010 Web Parts in Action

    SharePoint 2010 Web Parts in ActionIf you still haven’t picked up on my book about SharePoint Web Parts – SharePoint 2010 Web Parts in Action, then this is the chance for you. Today (5th of April) the book is featured as the Manning Deal of the Day. All you have to do is browse to http://www.manning.com/wilen/ and then use the dotd0405au promotion code. This will give you 50% percent discount, for you non-math-geniuses that’s half off the full price! And since you now saved a couple of bucks, there’s another Manning book with the same deal and promotion code today and that’s PowerShell in Action 2nd edition.

    PS: Even though the name of the book implies SharePoint 2010, it’s fully applicable to SharePoint 2013 – very little has changed in the Web Parts space.

    Well, what are you waiting for, go get it…

  • Speaking at SharePoint Evolutions Conference 2013

    Tags: Conferences

    In less than two weeks I’m speaking at the SharePoint Evolutions Conference 2013 in London. It is as exciting for me as it is for all attendees. The conferences held by Combined Knowledge has proven over the last years to be the highlight of SharePoint conferences around the world – everything from the venue, to the people, to the sessions and to the parties are surgically planned and executed – no one leaves without a smile on their face and pumped with knowledge!

    As a speaker being selected for this conference is the by far the proudest moment of any SharePoint professional and I’m so glad that I’m back for another year, hanging around with the best of the best, and not only speaker wise – the speakers at the Evolutions conference are the people that knows the product inside out and work with the product in real projects.

    Speaker_Evo-2013-Banner

    This year I’m having one session called Extending SharePoint, Exchange and Lync 2013 with a custom WOPI Client. I will walk you through the WOPI protocol, which is what Office Web Apps Server 2013 (WAC) is built upon, and show you how to make your own WOPI client for custom file formats, for viewing, editing, previews etc. This will be an interesting session and show you a really interesting “partner opportunity”. I’ve prepared a good set of demos, so be there!

    Looking forward to seeing old and new faces at this conference. If you haven’t registered yet – there’s still a chance for you to get your very own ticket.

  • Renewed as SharePoint Most Valuable Professional (MVP) for 2013

    Tags: SharePoint, MVP, Personal

    I just received the confirmation that I am renewed as SharePoint MVP (Microsoft Most Valuable Professional) for my fourth consecutive year. It’s an honor being chosen among all the professionals around the world, especially now when SharePoint is getting more and more widespread and is being adopted by more and more companies worldwide.

    Microsoft MVP

    I’d like to take the opportunity to say thanks all my colleagues at Connecta, that put up with me, and all my friends around the world that I’ve learnt to know throughout these years. I’ll continue to write obscure blog posts and show up at conferences, and I will continue to organize the Swedish SharePoint User Group meetings.

    Thank you all for the support!

About Wictor...

Wictor Wilén is the Nordic Digital Workplace Lead working at Avanade. 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 seven consecutive years.

And a word from our sponsors...