Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Print three copies with field changes

Avatar

Level 2

 

I have a form with a print button. I need the button to print three copies with a field change on each copy. When I use this code the field jumps to the last value and prints it three times.

 

  1. Documenta.rawValue = "Original"
  2. xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0);
  3. Documenta.rawValue = "Acounting"
  4. xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0);
  5. Documenta.rawValue = "Departmental"
  6. xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0);

           

Any thoughts?

 

Thanks in advance.

 

3 Replies

Avatar

Level 10

Hi,

all you need a a function with a loop.


//Declare function


function printCopies (vField) {


  var vValues = ["Original", "Acounting", "Departmental"];


  for (var i = 0, j = vValues.length; i < j; i += 1) {


  vField.rawValue = vValues[i];


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


  }


}


// Execute function


printCopies(xfa.resolveNode("form1.#subform.Textfield1"));


Hope this helps!

Avatar

Level 2

thank you for your feedback.

Using the function it is still cycling through and prints all three copies with "Department" .

Avatar

Level 10

Um, you're right, the solution does not work properly.

I made another sample with a much more complex solution.

It uses a global variable to count the number of times the forma has been printed.

https://files.acrobat.com/a/preview/01c6a4be-5489-484f-8042-55a3ad697ccb