Skip to main content
This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
November 20, 2024

So, are the labels arranged on the page in a grid?  Something like 2 columns of 4 rows?  If so, how are the fields named? do you have a scheme? 

Or is there one label on the page, and you print it muliple times? 

 

There is no way for a script to executed each time a page is printed for printing multiple copies. But you could create your own print script, that increments numbers in a field inbetween printing new copies.  

 

See the PrintParams entry in the Acrobat JavaScript Reference.

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#firstpage

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
November 20, 2024

On label per page printed multiple times

PDF Automation Station
Community Expert
Community Expert
November 20, 2024

You could use a template page and spawn it for the number of copies you want to print, then just print once.

Known Participant
November 20, 2024

Do you know a tutorial that can show me what you are talking about, fairly new to form creation. Thanks

PDF Automation Station
Community Expert
Community Expert
November 20, 2024

This tutorial explains how to create, hide, and spawn template pages.  It is not specific your question about the fields, but this is how:

  1.  Create your 6 fields on page one (Named "Numbering1" through "Number6" in this example).
  2.  Copy the page by selecting the page in the pages panel, holding down the Ctrl key, and dragging downward until you see two pages.
  3. Rename the fields on page 2.  In this example, add an underscore to the end of each field name.
  4.  Add the following custom calculation script to the fields on page 1:

 

var ttlFlds=this.numPages*6;
event.value="1 of "+ttlFlds;

 

Change the number "1 of" to "2 of" etc. to matching the corresponding field name.

5. Enter the following custom calculation script in the fields on page 2:

 

event.value=(event.target.page+1)*6-5+" of "+ttlFlds;

 

The -5 is for the first field ("Numbering1_").  It should be changed to -4, -3, -2, -1, and -0 for the fields Numbering2_ through Numbering6_ respectively.

6.  Create a template page from page 2 and hide it.

7.  Create a non printable button field on page 1 with the following mouse up action script:

 

var rtn = app.response("Number of pages:");
if(rtn)
{
for(var i=1;i<Number(rtn);i++)
{
this.templates[0].spawn();
}
}
this.calculateNow();

 

8. Print the document.