Wednesday, August 20, 2014

Five Different Methods for How to Print SharePoint List Item

Posted in [SharePoint], [Technical] By Doug Allen @ 1/24/2014

Print a SharePoint list itemWell really there are four methods to print a SharePoint display form, and I’ll give you one method to print InfoPath-customized list forms.  If you’ve gotten to this page, it’s because you or your users make heavy use of SharePoint lists, and the inevitable request came up “Ok this is great, but I can’t print this item, help!”.  Off to Google we go, and there are a few different solutions out there.  Which is best?  What do I do?  Like most things with SharePoint, there is no one right answer (sometimes there is!), but some are definitely easier than others or better depending on your needs.  I'll show you a couple different common solutions out there in one place, and what worked for me. 

For the sake of this post, I’m assuming the platform is SharePoint 2010.  SharePoint 2007 and especially SharePoint 2013 would have different solutions using the new client-side object model (CSOM). 

Print an InfoPath-based List Items

Print an InfoPath SharePoint List ItemFirst, let’s take a look at the InfoPath version.  If you use lists a lot then you probably know you can customize a list display/edit/new form using InfoPath.  This can give you great flexibility with your form design, and keep things with the site owner in the business instead of having to call IT.  Customizing your list with InfoPath is out of scope of this post, but you can follow the basic steps from Microsoft or watch a video from SharePoint-videos.com

For this solution, most folks I have seen turn to Chris Kent’s solution on codeplex that ONLY works with SharePoint list forms that have been customized with InfoPath.  It installed and worked fine, and added a button to the form and printed the form great!  However, a very annoying popup “Chris Kent is awesome” kept popping up every time it was printed.  We modified the solution code to remove this = happy client!  It adds a Print section on the ribbon and Print icon on the actual list item like the image on the right.  I have used this, and it filled the need.

The solutions below will also work for an InfoPath form, where you edit the display form, but of the item.  These steps are outlined here.

Print a Default SharePoint List Item

The rest of these solutions deal with how to print default SharePoint list items.  A couple of these are similar requiring no-code (server side anyway), and one that is a full server-side solution. 

Solution 1 – Use SharePoint Designer and a Custom Action

I think this is the easiest and takes only a minute to implement.  I first saw this mentioned in a TechNet forum post, and I was unable to find it again, sorry to the author!  This solutions involves SharePoint Designer to create a custom action on the list.  Let’s knock this out:

  1. Open SharePoint Designer 2010, click Open Site, and open the web that contains the list in question.
  2. Click Lists and Libraries on the left, and click on the List that you want to add the print button.
  3. On the ribbon under List Settings, click Custom Action –> Display Form Ribbon.
        SharePoint Designer custom action
  4. Fill out the Custom Action screen.
    1. Give it a name and optionally a description.
    2. For the “type of action”, choose Navigate to URL and input the following:
      javascript:window.print()
    3. List a 32x32 print icon if you have one.
    4. For the Ribbon Location, this should already be filled out as Ribbon.ListForm.Display.Manage.Controls._children.
      1. You can find all of the default ribbon locations on MSDN.
      2. For my list, I changed “Manage” to “Actions” so the icon would appear in the Actions group and not the Manage group.
    5. Configure Rights Mask and Sequence as needed, but defaults can be used just fine.  All available options for Rights Mask can be found here.
    6. Click OK, and you’re done.

Go open your list, and open in display form.  You should see something like this.  It’s not perfect, it’s a little small but it works and took less than 2 minutes.  Try it out!  You go a little further to clean it up by using some CSS to strip out the top nav and social icons and such using a technique similar to a previous blog I wrote to print a picture library

Print a SharePoint List Item

Solution 2 – Use a Content Editor with jQuery

There are a couple different flavors of this, but the core solution is the same.  Using the SharePoint UI, go to the list, edit the default list form via the ribbon, insert a content editor web part, and either embed the code on the page or call the code via a .txt file that fires the code via a button on the page.  If you follow Emerson Bruce’s method for this, she gives some nice CSS to help clean up the view and make it nice for printing. 

Solution 3 – Make a Print Item Column

Jim Parker over at www.nothingbutsharepoint.com did a nice write-up solution where basically we’re doing the same thing, but instead of a button on the page, we stuff the HTML in a calculated column that’s clickable that loads a nice print version that then you can just use your browser File->Print.  Nice Jim!

Solution 4 – Full Custom Solution

If you needed this on a list of lists, you don’t want to have to edit all these lists, you want to make a feature that just does it.  Bob Guidinger put a nice post using a server-side Visual Studio solution.  While his example shows attaching to InfoPath list forms, you just need to change the Location and Button ID to work with regular list forms.  Again, all of the default ribbon locations are on MSDN.

Wrap Up

I saw another post of using Access forms to do this, however, how do I say this … no thanks.  But for thoroughness, the link is provided.  I hope this helps show the different ways folks in the community have come up with to address this need, and you try them out and find the one that works for you. 

 For more information on C5 Insight or this blog entry, please Contact Us 

, , , ,

Comments

Got something to say? Join the discussion »
    Posted by Bob Guidinger on 7/9/2014
    Thanks for linking to my blog! I've updated my post so the solution works with SharePoint 2013, and also updated the XML so it adds to button to standard list forms.
    Posted by Eugene on 2/25/2014
    Thanks for the reply. I was able to extract the files, edit elements.xl and then use makeddf to re-create the wsp.

    Posted by Doug Allen on 2/24/2014
    Eugene,

    While I didn't remove it, one of our developers did, you will have to use Visual Studio, make a change to the code and re-compile the solution. Under InfoPathPrinter in the elements.xml, this line is causing in the CommandUIHandlers section:

    SP.UI.Notify.addNotification('Chris Kent is Awesome!');

    Remove it, recompile, deploy and you should be good.
    Doug
    Posted by Eugene on 2/19/2014
    How did you remove the Chris Kent popup?
    Posted by Eugene on 2/19/2014
    How did you remove the Chris Kent popup?
    Posted by Asif Rehmani on 1/24/2014
    Thanks for linking to our video at SharePoint-Videos.com. Hope the readers find it useful!

leave a reply

 [Quick Submit with Ctrl+Enter]

Remember my details
Notify me of followup comments via e-mail

C5_Insight

About C5 Insight

We are a Microsoft Gold Certified partner focusing on SharePoint, Microsoft Dynamics CRM and Salesforce.com.  Learn more about us by visiting our website.

Search

We Wrote the Bible on Microsoft SharePoint and Dynamics CRMBook-Microsoft Dynamics CRM 2011 and SharePoint 2010 Bible

Tags

Maximize

Recent Comments

Maximize

Blog Roll

Maximize

Disclaimer

The information herein may be used solely at your own risk.  No warranty is made by the author or by C5 Insight, Inc.

The opinons expressed herein are those of the individual authors and do not necessarily represent C5 Insight, Inc in any way.

Copyright 2011-2013 by C5 Insight