Expand my Community achievements bar.

SOLVED

Is there a script to tell the print button which pages to print

Avatar

Level 4

We have a form with 23 pages, the first 6 pages are instructions. We would like the user to be able to print out these instructions separate from the rest of the document. Then we would like another print button at the bottom of the document to print the remaining pages which are actually an application which needs a signature (17 pages).

The current print script is:

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

and it prints the entire document.

Thanks for your help.

1 Accepted Solution

Avatar

Correct answer by
Level 8

xfa.host.print(0, "6", "22", 0, 0, 0, 0, 0); will print pages 7 to 23 with no prompting.

View solution in original post

8 Replies

Avatar

Level 4

Ok, I'm sorry but I am script challenged and that page means nothing to me. Is there a way to change that script above to make it print pages 1 thru 6 and then another print button scripted to print 7 thru 23?

Avatar

Level 8

xfa.host.print(0, "0", "5", 0, 0, 0, 0, 0); will print pages 1 to 6 with no prompting.

Avatar

Correct answer by
Level 8

xfa.host.print(0, "6", "22", 0, 0, 0, 0, 0); will print pages 7 to 23 with no prompting.

Avatar

Level 4

Ok and then how would I tell it to print pages 7 thru 23?

Avatar

Level 10

Hi,

The print method requires eight parameters.

The second parameter "0" is the start page for the printout, using a zero-based numbering system. Eg "0" is the first page.

The third parameter (xfa.host.numPages -1).toString() is a calculation for the last page to be printed in the range. It calculates the total number of pages and then subtracts 1 to get it into the zero-numbering system and then converts it to a string for the print method.

So in your case the Print Instructions button would have the following script in the click event (changing the finish page):

xfa.host.print(1, "0", "5", 0, 0, 0, 0, 0);

And your Print the Rest of the Form button would have the following (changing the start page):

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

Make sense?

Niall

Avatar

Level 4

You anticipated that I wouldn't know how to script the second button. It prints beautifully, you are a genius. However it does prompt before printing. It says "This document is trying to print. Is this ok? )  ever so politely. I can live with that. Thank you very much.

Avatar

Level 4

Thank you for seeing that I was struggling with this and for helping out. You script is going right on my wall. This prints much more smoothly. Thank you, thank you, thank you, as always.