These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Batch printing livecycle forms with sequential numbering in a text field

Bloo1984
Registered: Jan 23 2011
Posts: 4
Answered

I'm relatively new to coding and wondered if anyone can help me. I'm using livecycle designer 8.2 and acrobat 9 pro
 
I'm looking to print a batch of forms (about 1000). I am looking to have a unique serial number be displayed on each seperate form in a text field which increases by one as each page is printed (e.g. RK0001 to RK1000)
 
Can anyone supply a script that will cover this

My Product Information:
LiveCycle Designer
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Accepted Answer
Hi,

this can be be done with a for loop.

Assuming you have a numeric field "Serial" in your form on a subform called "Page1", your form hierarchy should look like this:

form1
Masterpages
...
Page1
Serial
...

When you know the structure of your form you can access the field "Serial" directly from Acrobat's console window with:
this.xfa.form.form1.Page1.Serial.value.float.value
Sourrounded by a for loop you can do this repeatedly do raise the number and then print the form.

  1. for (i=1; i<1000; i++)
  2. {
  3. this.xfa.form.form1.Page1.Serial.value.float.value = i;
  4. this.print(false);
  5. }
PS: To have the desired look of the serial add the view pattern to your numeric field.
num{'RK'9999}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Bloo1984
Registered: Jan 23 2011
Posts: 4
Thanks for the reply, code works perfectly.

I would in time be looking to send the forms to a printing company to have them mass printed.

Is there a way of coding the form so that when they print the form it will automatically print different serial numbers on each print in increments of +1 without them having to input the code.
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Sure,

you can use a button in your form for example.
The script for the click:Event is generally the same, but uses the Designer print method.

  1. for (i=1; i<1000; i++)
  2. {
  3. Serial.value.float.value = i;
  4. //Silent print to default printer = no dialog shown
  5. xfa.host.print(0, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0)
  6. }

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Bloo1984
Registered: Jan 23 2011
Posts: 4
Perfect thanks for the help
banky007
Registered: Sep 15 2010
Posts: 3
Hi Radzmar,
Thanks for sharing your wealth of knowledge,I have to complete a similar task (trying to batch print copies of the same form with +1 increment on serial number on each form).

I have tried the codes above, ensuring that the form hierarchy is mapped to match your code, and using a button for click event, but the nothing happens when I click on this button../ I do not know what I am doing wrongly Radzmar..please can you help me?

Banky007
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

do you get any error in the JS console of Acrobat, when you run the script?

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

lokee2013
Registered: May 18 2011
Posts: 1
Hi,

I am running LC Designer 8.2 and Acrobat 9 pro and looking for a similar solution as the above posters. I haven't done any coding before and am brand new to LiveCycle.
I have a form that needs to be printed thousands of times, but only a few hundred at a single printing. It needs to have a serial number starting with 3001 printed in this format "No: 003001" and incrementing by one as each sheet is printed. I have so far created a numeric field and was able to format the "No: 00" using the Pattern dialog. The coding for the incremented loop and an understanding of the 'hierarchy' within LC Designer is where I need help.
Any assistance would be very much appreciated!
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

this could be don the following way.
Create a form with 3 numeric fields (serialStart, printAmount, serialNumber) and a button.
Add this script to the click event of the button.

  1. var Start = serialStart.value.float.value;
  2. var Amount = printAmount.value.float.value;
  3.  
  4. for (i=Start; i<Start+Amount; i++)
  5. {
  6. serialNumber.value.float.value=i;
  7. xfa.host.print(0,"0",(xfa.host.numPages -1).toString(),0,1,0,0,0)
  8. }
In the field "serialStart" you enter the number to start the count.
In "printAmount" the number of print.
When you click the button a loop will increase the "serialNumber" and print out a copy of the form as often as indicated by "printAmount".

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs