Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I edited the form for a list item in InfoPath, and when I print, I just want to print the form itself.

It seems when I use the browser's print function, it still pulls up some elements from the page and it cuts off the content if it's longer than the popup window. Also, some of the elements of the form are hidden when I print, so that is not a good option.

I have read that others have attempted to create a custom action that resides in the InfoPath Ribbon, but I have yet to find one that works?

Here is an answer for this but we are unfamiliar with Java Script.

Maybe it will give you some direction: what we did in this case was to add a simple Print button (we used Content web part, but you can do whatever). The print button uses JS to cut out only the relevant portion (based on DOM/CSS) and show it in a new window - basically we open the form in a new window and pass a QS parameter, the JS picks it up and cleans the form. Worked well and was very simple to do, just a few lines of javascript

Does anyone have the Java Script code for this?

share|improve this question

migrated from stackoverflow.com Dec 4 '12 at 3:10

This question came from our site for professional and enthusiast programmers.

2 Answers 2

Arsalan, are you sure that we can add code to a list form? The actual requirement is for a print option for a list form and where in my knowledge, we cannot have code for List form instead we can have for Library form.

The other approach what i would like to suggest if code is not possible in list is : create a webpart pgae, add a infopath form webpart and place the infopath list form on that webpart. on the same webpart page, add a content editor webpart and add html button and write onclick javascript function and execute window.print statement.

plz correct me if i am wrong.

thanks

share|improve this answer

You can follow these steps for that,

1) Paste “thisXDocument.PrintOut()” under the code of Print button you placed.
2) Give full trust to your form and sign it.
3) Now publish the form either to sharepoint or localdirectory.
4) Open the published form and click that Print button .
5) A dialog will be displayed asking you to save that file with an extension “mdi”.
6) Click on save and you will see the print preview of that form.
7) You can now do whatever you want regarding printing.

Ref: http://www.infopathdev.com/forums/p/2041/8667.aspx

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.