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 Print button needed on forms?
By default there is no print button on SharePoint forms.
Step 1: Enable Modeless forms
By default the view/edit forms are opened in dialog forms. We need to change this to edit the page.
Choose List > List Settings > Advanced Settings
Set the last option to No.
Now you can see the View form is opened in full page mode.
Following is the 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 & enter the following HTML contents.
<input onclick=”window.print();” type=”button” value=”Print”/>
Click OK to save the changes. Choose Stop Editing from the page tab. The page will look like below.
We added a Print button which will invoke window.print() method on click.
Step 3: Test the page
Refresh the list & open a list item in View Page. Click on the Print button & you can see the Print Dialog appearing like below.
This confirms the print functionality integration. You can also repeat the same for Edit form.
Step 4: Enable back dialog
Now we need to enable back the dialog form. Go to List Settings > Advanced Settings & enable the Dialog option.
You can see the Print button there too.
The print() method prints the contents of the current window.
For having a custom action you can refer the solution below:
In this article we have explored a scenario of showing Print button on InfoPath forms.