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

Sequential numbering

eabikhzer
Registered: Jul 8 2008
Posts: 29

Hello,

I have to print a 1 page pdf document. But I want there to be on top of the page a sequential number that would appear when I print for example 500 copies. There would be 001 on the first, 002 on the second, etc...
Can anyone help me with that?

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Create a text field (let's say it's called "Text1"). Enter 0 into it.
Now go to Advanced - Document processing - Set document actions.
Select "Document will print" and click Edit.
Enter the following code to the window that opens:

this.getField("Text1").value++;

Press OK until all the dialogs are closed. Save the file.
You're done.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

eabikhzer
Registered: Jul 8 2008
Posts: 29
Hi, thank you for your reply. I tried doing it but this is what happens:

I set the field default value to "1" and I put in the code exactly as you gave it to me. Then I printed 3 copies to make a test. What was supposed to happen was that the first copy have a "1", the second a "2", the third a "3". Instead all 3 copies had a "2".

Any help?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
First, you need to set the default value to 0 since the 'Will Print' action will increment by '1', the "++", the field value before printing the form.

If you set the number of copies to print through the UI, you will printing the PDF copy x times which is different than printing the PDF x times, you need to trigger the 'will print' action 500 times.

Next you will need to open the Acrobat JavaScript console and run the following code:

this.resetForm(); // clear the form// print 500 individual timesfor(i = 1; i < 500; i++) {this.print();}

You can use a button unless you write a special script for a hidden print action.

George Kaiser

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Hmm, I sent a similar message to gkaiseril's, but it doesn't seem to appear here for some reason.
Anyway, what he said is correct. Just be aware that it might overwhelm your printer to do this (sending 500 print commands in one time).

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

secondcity
Registered: Dec 3 2009
Posts: 2
Hi There,

The previous posts were very helpful, thanks.

Just wondering how I might use this scenario while having leading zeros:
0001, 0002, 0003... as opposed to 1, 2, 3...

Cheers
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You will need to use the 'util.printf()' method to format the number to have leading zeros appear in a text field with no formatting.

George Kaiser

secondcity
Registered: Dec 3 2009
Posts: 2
I'm new to this script writing so I hope you can bear with me.

After a bit of research it looks like I need to use something like this to get leading zeros:
util.printf("%04d", "text1");

I'm just trying to figure out where to put it. I've tried putting it in the "Text Field Properties" under "Calculate", then I tried adding it to the action in "Document Will Print".

Here's what I had before trying to add util.printf():

-A text field "Text1" with default number set to 0

-under "document will print": this.getField("Text1").value++;
-runing this script:
this.resetForm();
for(i = 0; i < 100; i++)
{
this.print();
}

would love any help.