Print Button on InfoPath Form in SharePoint 2010

In this article we can explore a real-life scenario to show a Print button on an InfoPath form in view/edit mode. You can also extend the solution to other list forms.

Why the Print button is needed on forms

By default there is no print button on SharePoint forms.

SharePoint forms

Procedure

The following is the procedure to create a Print button. We are using HTML and JavaScript for the solution.

Step 1: Enable Modeless forms

By default the view/edit forms are opened as dialog (modal) forms. We need to change this to edit the page.

Choose "List" > "List Settings" > "Advanced Settings"

Advanced Settings

Set the last option to No.

Now you can see the View form is opened in full page mode.

View form

The following is the Edit form.

Edit form

Step 2: Edit Page

Open a list item in View Form, choose the "Site Actions" > "Edit Page" option to bring the page to edit mode. Add a Content Editor Web part and enter the following HTML contents.

<input onclick="window.print();" type="button" value="Print"/>

Edit Page

Click OK to save the changes. Choose Stop Editing from the page tab. The page will look as in the following.
 
Stop Editing

We added a Print button that will invoke the window.print() method on click.

Step 3: Test the page

Refresh the list and open a list item in View Page. Click on the Print button and you can see the Print Dialog appearing as in the following.
 
Print button

This confirms the print functionality integration. You can also repeat the same for the Edit form.

Step 4: Enable back dialog

Now we need to re-enable the dialog form. Go to "List Settings" > "Advanced Settings" and enable the "Dialog" option.
 
Advanced Settings

You can see the Print button there too.

Note

The print() method prints the contents of the current window.

Custom Action

For having a custom action you can refer to the solution below:

WireBear InfoPath Printer
 
solution below

References

Window print() Method

Summary

In this article we explored a scenario of showing a Print button on InfoPath forms.

Up Next
    Ebook Download
    View all
    Learn
    View all