Highlighted

Printing in a form

Avatar

Avatar

_Tim_Henderson_

Avatar

_Tim_Henderson_

_Tim_Henderson_

08-12-2008

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.

Replies

Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

08-12-2008

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.
Highlighted

Avatar

Avatar

_Tim_Henderson_

Avatar

_Tim_Henderson_

_Tim_Henderson_

08-12-2008

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);



?
Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

09-12-2008

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
Highlighted

Avatar

Avatar

_Tim_Henderson_

Avatar

_Tim_Henderson_

_Tim_Henderson_

09-12-2008

Thank you so much. That is what I think I needed.
Highlighted

Avatar

Avatar

Ryan_Lunka

Avatar

Ryan_Lunka

Ryan_Lunka

09-12-2008

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
Highlighted

Avatar

Avatar

Niall_O_Donovan

Total Posts

4.4K

Likes

645

Correct Answer

786

Avatar

Niall_O_Donovan

Total Posts

4.4K

Likes

645

Correct Answer

786
Niall_O_Donovan

01-02-2009

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