Print three copies with field changes

Avatar

Avatar

pauly225

Avatar

pauly225

pauly225

02-03-2015

 

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.

 

Accepted Solutions (0)

Answers (3)

Answers (3)

Avatar

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485
radzmar
MVP

03-03-2015

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

Avatar

Avatar

pauly225

Avatar

pauly225

pauly225

02-03-2015

thank you for your feedback.

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

Avatar

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485
radzmar
MVP

02-03-2015

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!