• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Adobe Acrobat Pro Duplicate input for Different Pages

New Here ,
May 30, 2024 May 30, 2024

Copy link to clipboard

Copied

I am creating an interactive document in pdf. The page in the document has two buttons: add and remove. When the add button is pressed it adds another page from the same template using the code above. When the remove button is pressed it removes the current page.

add button code: 

 

template.spawn({nPage: this.pageNum + 1, bRename: true, bOverlay: false});

 

remove button code: 

 

this.deletePages({nStart: this.pageNum});

 

My problem is that if I add a page it will be called 'P1.myTemplate.myField' then if I click the add button to add another page, the new page will be called 'P2.myTemplate.myField'. Now if I click remove and delete the first page 'P1.myTemplate.myField' and then go to page 'P2.myTemplate.myField' and click add the new page will also be named 'P2.myTemplate.myField'. Which causes the input in the text fields to duplicate across both pages.

 

Visual representation:
Note: Page Name refers to the name adobe gives the elements in the page and page number refers to the actual page number in the document.

First Page
Page/Object Name:      P1.myTemplate.myField
Page number:                                   1                                

Add second Page:
Page/Object Name:      P1.myTemplate.myField   P2.myTemplate.myField
Page number:                                   1                                           2

Delete First Page:
Page/Object Name:      P2.myTemplate.myField
Page number:                                    1

Add second Page:
Page/Object Name:      P2.myTemplate.myField   P2.myTemplate.myField
Page number:                                    1                                           2

Is there a way I could control how adobe names the pages? or any work around for this issue? What is recommended to do for dynamic PDF forms?

TOPICS
Create PDFs , JavaScript , PDF , PDF forms

Views

233

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 30, 2024 May 30, 2024

Copy link to clipboard

Copied

As far as I know, you can't control how Adobe names the fields in spawned pages.  You can add a script in the Add Page button that hides the Delete Page button on the same page so the Delete button will only be visible on the last added page, and also add a script in the Delete Page button that makes the Delete button on the previous page visible again.  This way, the user has to delete the pages in the order they were added.  IDK if that meets your needs.  Here's an article that explains how to do this:

https://pdfautomationstation.substack.com/p/buttons-that-add-and-delete-pdf-pages

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 30, 2024 May 30, 2024

Copy link to clipboard

Copied

Spawn pages only at the end of the document.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 03, 2024 Jun 03, 2024

Copy link to clipboard

Copied

LATEST

Acrobat names fields on spawned pages according to a simple pattern.

p<Page Num>.<Template Name>.<Field Name>

 

So, you have be careful when spawning to a particular page.  Spawned pages must be consecutive.  

There are several ways you could keep track of the spawned page number, but an easy one is to just keep it in hidden text field on the form.    

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines