Skip to main content
uweb40795041
Known Participant
March 23, 2020
Question

Consecutive numbering when using templates

  • March 23, 2020
  • 1 reply
  • 373 views

Hello together,

I'm currently creating a form in which following pages can be spawned by templates.
For this I need consecutive numbers on the newly created pages which are aligned with the last number of the previous page.
I also have a plan how I want to do this. But I need the prefix of the previous page. How to determine the prefix of the current page I have found out. But how do I determine the prefix of the previous page?

"

var prefix = "";
var re = /(.+\.)(.+)/g;
var res = re.exec(event.target.name);
if (res != null)
{
  prefix = res[1];
}

"

Thanks in advance for helping.

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
March 24, 2020

First, the prefix is always the number of the page where the template is spawned. So if it's spawned on page 25, the prefix is "P25".  

So, there are several options for determining the prefix of the previous page.

 

1) If pages are created consecutively, then the previous prefix is just the previous page number. 

2)  You're script is creating the pages, so use a hidden field to track the numbers

3) Search all the field names to find all instances of the template, then workout which one is previous to the one on the current page.  

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often