Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Printing in a form

Avatar

Level 2
I have come out here in the past and been able to get some really great help. I hope that it continues. I have a 26 page document that has a 9 page form in it. I would like to be able to put a print button in that automatically sets it up to print just the form. Can someone please tell me it this can be done? Thank you.
6 Replies

Avatar

Former Community Member
In the print command you can pass a page range to print. Note that this will only work if your users press the print button on your form and not the Print command on the toolbar or Ctrl-p.



The second parameter is a 0 based page number to start at and th e3rd parameter is a 0 based paged number to end at.

Avatar

Level 2
Paul,



Like always you are a great asset to these forums. Thank you but I have one more question to add to this. I just put in the button and the code that was created was



xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0);



So based on what your telling me, to print from pages 16 to 24 I would put in



xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 16, 24, 0, 0, 0);



?

Avatar

Former Community Member
No you would put in:



xfa.host.print(1, "16", "24", 0,1,0,0,0)



Note that the page numbering is 0 based so you may have to use 15-23

Avatar

Level 2
Thank you so much. That is what I think I needed.

Avatar

Former Community Member
You could also, in the pre-print event, hide all of the pages that will not be printed. Then in the post print event, you show them again. That may get the effect you need.



Ryan Lunka

Cardinal Solutions Group

rlunka@cardinalsolutions.com

Avatar

Level 10
Hi,



Just to add my experiences to the melting pot...



I have a multi page form, in which the number of pages grow depending on user inputs. At the end I have a series of individual pages that the user can print off. I wanted a button on each page that when clicked would print off that one page only. Because I did not know the page number at run time, I set up a numeric field (hidden) called this_page with the following Javascript in the Layout:Ready event:



"this.rawValue = xfa.layout.page(this);"



Then in the regular button click event I had the following Javascript:



"xfa.host.print(1,(this_page.rawValue -1).toString(), (this_page.rawValue -1).toString(), 0, 0, 0, 0, 0);"



Therefore no matter what the number of pages visible at run time, the button would print off that one page. There was one incidence where I wanted the button to print off two consecutive pages and all I had to do was amend the 3rd variable to "(this_page.rawValue).toString(),".



Hope this helps...



Regards,



Niall