How to Add a Print Button to InfoPath Forms!

A common complaint I hear about custom InfoPath forms on lists and libraries is that you can’t print them. If you try and use the print button through the browser, you will likely end up printing the entire page. If you take a screenshot, you might not capture the entire form.

We can fix all these problems by adding a “Print” button to the forms

Adding a Print Button to InfoPath Forms.

Read on to find out how!

First, open up Visual Studio 2010, and create an empty SharePoint project. In the project, add a new element, and add the following to it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  <CustomAction Id="PrintButton" Location="CommandUI.Ribbon" Rights="ViewListItems">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
          Location="Ribbon.Tabs.InfoPathListDisplayTab.Manage.Controls._children">
          <Button Id="Ribbon.Tabs.InfoPathListDisplayTab.Manage.Controls.Print"
            Command="Print"
            LabelText="Print Item"
            Sequence="16"
            TemplateAlias="o1"
            Image16by16="/_layouts/images/printer.png"
            Image32by32="/_layouts/images/printer.png"/>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
         Command="Print"
         CommandAction="javascript:window.print();" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>

You will notice in the XML above that we reference an image file. This is the icon that will show in the ribbon. You can download the image I used from here. You must place this file in the SharePoint root (14 Hive) as show in the image below.

How to Add a Print Button to InfoPath Forms!

Make sure you have the element added to a feature, and deploy the solution to your farm. After you deploy your solution and activate the feature, you should see a Print button on the display view of your forms. When the print button is clicked, it will bring up the Print dialog from the browser…and it will only print the form!

If you don’t have access to Visual Studio 2010 (or prefer not to dabble in custom coding), you can download the .wsp file from here. To deploy, open up PowerShell on your SharePoint server, and run

1
2
3
Add-PSSnapIn Microsoft.SharePoint.PowerShell
Add-SPSolution C:\path\to\bguidinger.PrintButton.wsp
Install-SPSolution -Identity bguidinger.PrintButton.wsp -GACDeployment

Hopefully this helps you (and your end users) out!

By |2016-11-02T17:15:18+00:00October 19th, 2012|Our 2 Cents, Our Blog, SharePoint 2010, SmackTalk|0 Comments

About the Author:

Leave A Comment

Did You Know….

GWEN-GARCIA-LEETS-IMAGEN-OFICIAL-SWN..Gwen Is the official spokeswoman of Smackwagon Design! GWEN Garcia Leets, is also sponsored by other internationally renowned companies. GWEN Currently is a host on an entertaining television program in Mexico called Marathon TeleHit

Interested in learning more about this beauty ? Click here to view GWEN's website to & keep you always informed of her most recent projects and events

CALL US TODAY!