Home > SharePoint > SharePoint 2010 Infopath Print Button

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/

  1. Samara
    May 17, 2011 at 7:43 am

    Awesome!

  2. Katelyn Ho
    May 18, 2011 at 5:18 pm

    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.

    • May 18, 2011 at 11:51 pm

      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.

  3. Paul Mujica
    June 20, 2011 at 10:35 am

    Excellent guide. Thank you very much for making it.

  4. Steve
    June 22, 2011 at 4:27 pm

    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

  5. Steve
    June 23, 2011 at 3:35 am

    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 !

    • ForDummies
      January 17, 2014 at 9:20 am

      Do you have a screen capture to show what buttons you hit to get there?

  6. Anurag
    September 7, 2011 at 4:07 am

    Can you make this work in a document library instead of a custom list ??

    • September 7, 2011 at 10:09 am

      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

  7. Arnold van Loon
    October 12, 2011 at 9:01 am

    Just spend 2,5 hours reading all sorts of BS on this subject. This is a brilliant solution, thanks..

  8. Jim
    October 17, 2011 at 11:24 am

    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

  9. Corrie Sigler
    December 28, 2011 at 10:33 am

    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?

    • December 28, 2011 at 12:33 pm

      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.

  10. Jovix
    February 2, 2012 at 11:11 am

    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.

  11. Mona
    February 15, 2012 at 11:36 am

    Simple, thanks!

  12. April 25, 2012 at 8:59 am

    Great tip. Thanks.

  13. April 27, 2012 at 10:13 am

    Perfect, Thanks a Lot !

  14. Marco
    June 26, 2012 at 7:58 am

    Perfect tip. Thanks!

  15. alan-p
    June 29, 2012 at 6:58 pm

    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!

    • June 29, 2012 at 8:00 pm

      You might be able to make some font changes using CSS or by changing the size in the Infopath form.

      • alan-p
        July 9, 2012 at 8:07 am

        Thanks for the response. Changing the infopath form font size has little impact on the print area of the form.

  16. Rashmi Menon
    July 11, 2012 at 10:24 am

    This is great. Is there a code for “Save As” as well. I want this to save as a pdf or word document.

    • July 11, 2012 at 10:46 am

      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.

  17. Rashmi Menon
    July 11, 2012 at 1:07 pm

    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?

  18. Link
    September 7, 2012 at 4:12 pm

    Thank you thank you thank you!! Seriously thank you!!

  19. Tony
    September 18, 2012 at 9:13 pm

    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!!!!!!!!

  20. Bhargav
    October 18, 2012 at 5:34 am

    Excellent post !! Thanks a ton.

  21. Simone
    October 26, 2012 at 8:22 am

    Perfect! thanks!

  22. Candice
    October 31, 2012 at 8:41 am

    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!!

  23. Jorge
    November 6, 2012 at 3:33 pm

    Thank you, your help temporarily improved my day at work.

  24. Corrie Sigler
    November 15, 2012 at 3:07 pm

    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

  25. Dianna
    April 11, 2013 at 4:10 pm

    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!!!

    • April 11, 2013 at 10:56 pm

      You do have to put in some code to make my solution work. Were you able to get through any of the steps above?

      • Dianna
        April 12, 2013 at 10:01 am

        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?

    • April 12, 2013 at 11:34 am

      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.

      • Dianna
        April 12, 2013 at 3:27 pm

        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! 🙂

    • April 12, 2013 at 4:16 pm

      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.

    • May 8, 2013 at 9:59 am

      Thanks for sharing. I’ll add that as an alt-solution up above.

    • May 22, 2013 at 3:46 pm

      thank you for sharing this! i’ve been researching this topic for months now!

  26. Supriya Khamesra
    August 14, 2013 at 7:29 am

    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

  27. markus
    September 19, 2013 at 4:28 am

    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

  28. ForDummies
    January 17, 2014 at 9:19 am

    Is there a “for dummies” version of this that shows screen captures for the final steps? I can’t

  29. Kim
    July 11, 2014 at 1:11 pm

    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.

  30. Tinq
    February 9, 2015 at 12:24 pm

    Just as Candice, Tony and Marco stated, I was ready to pull out the rest of my hair before coming across this. THANK YOU

  31. Shubh
    April 22, 2015 at 4:18 am

    will this work with Form Library, as my form is in Form Library..

  1. No trackbacks yet.

Leave a comment