Printing the Display View of an InfoPath List Item Form

Applies To: SharePoint 2010

I’ve written previously about a cool feature in SharePoint 2010 Server Enterprise that allows you to customize list item forms using InfoPath. It’s really simple to do and you can get some pretty cool results in just a couple of minutes. For instance, I posted a while back about how to use SharePoint column validation to validate email addresses and phone numbers. Those are still good techniques, but by using an InfoPath list item form it’s just a validation drop down (you can even do regular expressions) and you’re done!

So the ease of validation, conditional hiding of fields, etc. are all pretty useful. However, the thing I like it most for is the ability to use different InfoPath views to match the list item views. So you can have different columns available when you’re editing than when you’re adding a new item, for instance. I especially like to spruce up the Display form.

(For some quick tips on how to get the different views working check out the top of my old post)

So, let’s say you’ve got a nice looking display form. Users open that thing up and decide to print. There’s no button, so they use the print button in the browser. Generally they’ll end up with some mess that prints all of your branding, usually some of the list behind the modal dialog, and if you’re lucky mixed in there somewhere will be your display form. Obviously, that’s not going to cut it.

So I did some digging and found some examples of people using javascript to print the form and their solutions were pretty intriguing. But I didn’t particularly want to have to apply some javascript to every form or to have to add a content editor to the pages, etc. I wanted something that just worked on existing forms and new ones too. So I did a little research into Ribbon customization and came across this great series by Chris O’Brien.

I put it all together in a solution and put it over on CodePlex as WireBear InfoPath Printer. There’s some stuff about it’s license over there (Free for personal and commercial use, etc.) and the basic installation instructions. It’s super easy to setup since it’s just a standard SharePoint Solution that you globally deploy.

You can find the full source code over on CodePlex. It’s not too complex and I’ll probably explain most of it in the next couple of posts. Bottom line is that it adds a Print button to the Ribbon when viewing list items that use an InfoPath Form:

The final printout only shows the form (No Ribbon, No Header, No Footer, No QuickLaunch, etc.).

The button is added using Custom Action XML that is deployed as a feature in the solution. The XML is targeted to allow the button to only be present when Viewing a List Item using an InfoPath Browser based List Form.

When you click the button, standard JavaScript is executed to find the InfoPath div element on the page and to copy the form’s HTML into a new window (along with all standard CSS/script references already present) and uses the browser’s page printing. Once the print dialog closes, so does the window.

We’ve been using it around here for a while and almost no one even knows it’s a custom solution. It looks like part of the UI and it’s use is immediately understood. So, go get it (It’s free!) and let me know what you think.

28 thoughts on “Printing the Display View of an InfoPath List Item Form

  1. Chris, Good Day to You !

    I have some problems with this feature. After installation on my farm i can see the print button, but when i press it i see IE tab open’s and closed immediatly, no print window opens. Can you help me ?

  2. I am trying to find a solution that places a cewp button on my library page, but when clicked prints a specfic IP view for those documents selected. Anyone have any ideas?

  3. I have installed your print solution. It works great! How do I remove your easter egg?
    You don’t need to say it. Just getting the print to work proves your awesome!

  4. there have been a few similar solutions published which place a print icon on the ribbon above the infopath form display… tonight I tried all of them (i believe), including this one, and none actually seem to work (for me). the solution deploys just fine & the code is on both WFE servers, as expected. there is just no print button. From what I am finding, this seems to be a pretty random experience for folks attempting to use these custom solutions and I truly wish I knew where to start debugging as I could really use this exact functionality.

    If you have time to provide any insight re: why it may not work for some people, it would be very much appreciated.

  5. I am seeing the same issue as Eagler.
    “I have some problems with this feature. After installation on my farm i can see the print button, but when i press it i see IE tab open’s and closed immediately, no print window opens” any help?

  6. This absolutely perfect in every way! Great job! I do have one question, can you provide the wsp for it with out the Easter egg popup awesome message?

  7. As Dan M said,

    I have installed your print solution. It works great! How do I remove your easter egg?
    You don’t need to say it. Just getting the print to work proves your awesome!

    Could you also let me know how to remove the EasterEgg…. thanks 🙂

    Cheers,

    Daniel G.

    • To remove the popup: rename the wsp to cab (WireBear.InfoPathPrinter.cab), extract, open Elements.xml in your favorite editor, comment out or remove line 66.
      Rename to WireBear.InfoPathPrinter.wsp, deploy solution, done 🙂

  8. Hi Chris,

    Unfortunately, the solution doesn’t work for me either. I followed the installation steps and it was successfully deployed. Also verified 14 hive, where the images and feature of this solution were indeed deployed correctly. “Print” image doesn’t show. Could you please advice?

  9. Thanks Chris, Like the looks of this solution. Have you looked into making it deploy as a Sandboxed solution?

  10. Chris,
    I deployed the wsp using SharePoint powershell globally, however, I do not see this as a Feature when I look for it in the Manage Web Applications Feature for my specific Web Application.
    I have SharePoint publishing and enterprise site features enabled.
    What am I missing?

  11. Hi,
    Is there a solution with just javascript (webpart)? I have no exp with powershell and i’m not the server admin. But would like a printout that only shows the form (No Ribbon, No Header, No Footer, No QuickLaunch, etc.)…. Not the result like right click/print option.
    many thanks!

  12. Chris – this looks great. Do you have a SharePoint 2013 version of this solution? This looks REALLY good!

    Thx,
    Bill (Minnesota)

Leave a reply to Eugene Cancel reply