SharePoint – Adding a Print function to the Ribbon

Sometimes it would be nice to have the print icon at hand from the Ribbon or even the List Item dropdown menu.

image

Clicking the icon will bring up the Printer pop-up window.

image

It prints in this case to a PDF file.

image

To accomplish this you need to open the SPDesigner, go to the relevant List. And add a new Custom Action.

image

image

Add this JavaScript code to the button.

javascript:window.print();

Add a nice print ICON rightsMask and Sequence to it and that is it.

image

Adding a list Item Menu is simular, but you need to start for the SPD menu.

image

Make sure you add the icon to the 16×16 Button image URL Location.

image

 

Or you can as well add a print button, attached to a JQuery click event.

image

<td><button class=”printMe” type=”submit”  style=”font-size: x-small; font-family: Verdana; width: 100px; height: 23px;” >Print</button></td>

$(‘.printMe’).click(function() {
  window.print();
  return false;
  });

<script type=”text/javascript”>
$(document).ready(function() {

$(‘.printMe’).click(function() {
  window.print();
  return false;
  });

});
</script>

Enjoy !

Advertisements

3 Responses to SharePoint – Adding a Print function to the Ribbon

  1. Pete says:

    Using the javascript:windows.print() command for a List Item Menu custom action doesn’t work as one would want…this prints the List view, not the individual item.

    • Sure, that’s exactly what was meant to be?

      • Pete says:

        So I have a list of say 15 items, and I can click on the dropdown for each item and find a print icon, but pressing it prints the list, not the individual item…that makes no sense. That would be like clicking the delete button from the individual item’s dropdown and it deletes the entire list instead of the item. I’ve ended up solving this by using javascript to open the item in a new window (using {ItemUrl}), shifting focus to the new window, and then printing the new window.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: