SharePoint 2010 Infopath Print Button
SharePoint 2010 Infopath Print Button
I received a request to put a print button within a List Item display view so that one could easily print the current item they’re viewing. After searching for a way to put a print button within the Infopath form itself (and coming up empty), I figured out how to simply add it to the page that displays the form.
The end goal
Once you have your Infopath form put together and published to a List, go to the List page.
1. Click on the “List” tab under List Tools
2. Click on the drop down arrow on the “Modify Form Webparts” button (pictured)
3. Select “(Item) Display Form”
4. This will take you to an edit page screen with your Infopath form set as a webpart
5. Add a “Content Editor Webpart” to the page
6. Edit your new webpart’s source and paste in the following:
<input type="button" value=" Print this page " onclick="window.print();return false;" />
Note: <form> tags are not required
This adds a print button to the page that uses the default print call within a browser. Since we edited the “Display” form, the button will not appear if a user is editing the form or creating a new item.
Of course, the best part of this discovery is the added bonus of being able to add extra code to our Infopath forms, making them a much more versatile tool than they were before.
Update 5/8/13: One of the recent comments on this page had another solution that looks like it can provide a cleaner approach. I haven’t tried it, but others might like to http://thechriskent.com/2012/10/01/printing-the-display-view-of-an-infopath-list-item-form/
Awesome!
Hello,
After following your directions, I finally got the print button to show and print. However the print format doensn’t really print how the form should look but rather the page with the form. You can just right click the form when an item is open and print. Do you know if there a way to print the form only.
If you’re referring to printing a blank form, you would select “(Item) New Form” during step 3.
The print code itself simply uses the browser print features when it makes the call. If you’re looking to have it print in a different way, you may have to look towards a downloadable copy of your form. Hope that helps.
Excellent guide. Thank you very much for making it.
Hi, I am still stuck I’m afraid. After reading your guidelines on creating a print button, I got as far as Step 6:
“Edit your new webpart’s source and paste in the following:”
1 input type=”button” value=” Print this page ”
2 onclick=”window.print();return false;” /
At this point it did not work and I simply viewed the code as text in the list form when I reviewed it.
Not sure what i may be doing wrong here?
thanks
Hi, It’s me again, finally sussed it, realised I was being a bit dense (but then I’m not really a programmer! – You have to go to the HTML editor to insert the code 😦 ! Brilliant !
Do you have a screen capture to show what buttons you hit to get there?
Can you make this work in a document library instead of a custom list ??
You should be able to add it in any view that allows you to add webparts. I know that Document Libraries don’t let you customize their forms with Infopath, so you might not be able to edit that particular view. If you can find the button in step 2, you should be able to edit the View and Edit views
Just spend 2,5 hours reading all sorts of BS on this subject. This is a brilliant solution, thanks..
Hello,
I’m Jim and am certainly not a code writer and was able to enter the source code as described and when I select the button to print I received the following:
%%[ ProductName: Distiller ]%%
94dfuek not found, using Courier.
XFE408FC4 not found, using Courier.
%%[Page: 1]%%
11fnqjv not found, using Courier.
%%[ Error: invalidfont; OffendingCommand: show ]%%
Stack:
()
%%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
%%[ Warning: PostScript error. No PDF file produced. ] %%
Can anyone help please? 🙂
Jim
Worked like a charm! Now, how can I remove the SharePoint logo and path as well as the Print this page button from the top of my printed form?
I haven’t tried this myself, but you should be able to setup a print.css file that doesn’t contain the logo like a traditional webpage. Hope that helps. Let me know if it works out.
When I click the Modify Forms Webpart button i do not get what is shown in your screenshot. Instead I get the following “Failed to retrieve forms for list”. Any ideas why this would be? Thanks.
Simple, thanks!
Great tip. Thanks.
Perfect, Thanks a Lot !
Perfect tip. Thanks!
This is great, for what ended up being a nightmare with my users. Is there anyway we can get the font size bigger. The default print seems just too small for our users… Thank you!
You might be able to make some font changes using CSS or by changing the size in the Infopath form.
Thanks for the response. Changing the infopath form font size has little impact on the print area of the form.
This is great. Is there a code for “Save As” as well. I want this to save as a pdf or word document.
There might be a Javacript trick to forcing the print to switch to a PDF print, but otherwise your users can select “Adobe PDF” from the printer options in the default print screen.
For some reason the print command does not have pdf as one of the options. I am not sure why or how to add it. Any recommendations?
Thank you thank you thank you!! Seriously thank you!!
AWESOME!!!!! Worked BEAUTIFULLY!!! I was at my ropes end when I finially stumbled upon this site and found an easy to emplement solution that nobody else seems to have concieved! THANK YOU!!!!!!!!
Excellent post !! Thanks a ton.
Perfect! thanks!
Thanks for this! I have set this up for our project intake form and hope this will work for us! Though the font is small, it at least gives users the option to print after they have completed the form. I tried exporting to PDF but it still has the small font displayed. Thanks though!!
Thank you, your help temporarily improved my day at work.
I am trying to find info on creating a print cewp button to place on my library page that will print documents that have been selected BUT use a specific InfoPath View. Anyone have any suggestions? Been researching for days.
CS
Hello, I finally found a site that can help me create the print button, but I too am stuck in that the code shows up on the form and the button does not appear. I am absolutely NOT a developer, so if there is something additional that I have to do (which appears there is and only the developers know how to do this) can you please provide more information on how to accomplish this, all the steps please? One person indicated doing something in HTML, but I have no idea how/what/when??? Help!!!
You do have to put in some code to make my solution work. Were you able to get through any of the steps above?
I was able to get through step 5, which I cut and paste your instructions, saved and then relaunched. But the text shows up and not the button. What am I missing?
When you get to step 5 and you get to the part where you can edit the page, you want to look up in the ribbon for the “Edit Source” button. Unfortunately, it’s been a long time since I’ve worked with SharePoint so I can’t tell you where it is off the top of my head but it should be there (I think it might be under the “HTML” drop menu in the Formatted Text ribbon). By pasting the code into the source, the page will treat it as if it were HTML rather than just text to display. Hopefully that helps.
Thank you! I was able to add the button, but I could achieve the same results by opening up my form and right clicking with my mouse and selecting PRINT. Is there a way to a get a ‘quality’ print job without the URL addresses and the other nonesense? Looking like a printed WORD doc? That is the burning question, but I sure do appreciate you communicating back and forth with me, have a great weekend! 🙂
Unfortunately this is the only way I’ve been able to find. I didn’t have any luck finding a solution in Infopath to print the forms directly (or nicely for that matter). I could only get it to work through the print menu of the browser. Hopefully someone finds a better solution or they actually implement it as a feature in the future.
I use this: http://thechriskent.com/2012/10/01/printing-the-display-view-of-an-infopath-list-item-form/
Thanks for sharing. I’ll add that as an alt-solution up above.
thank you for sharing this! i’ve been researching this topic for months now!
hi,
I have used your code of displaying the print button on the Info Path form and able to get the button on form.But when I print the form the printing in not appearing in English language .It is some different language.
Can you please help me why the printing is appearing in different language. I have checked the browser language and is set as English only
Hi is this also possible in SP2013? I tried it with the skript editor webpart. Editing it it shows a button, but the button does not appear in the display form.
Many thanks!
cheers
Is there a “for dummies” version of this that shows screen captures for the final steps? I can’t
Hi I was able to add the button and print out the page that containts the form, however I have text box field that user enter text, and it is not able to print all the text in the field. how to fix that? do i have to go in custom form to adjust the text box properties instead.
Just as Candice, Tony and Marco stated, I was ready to pull out the rest of my hair before coming across this. THANK YOU
will this work with Form Library, as my form is in Form Library..