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

JavaScript Add Page, Delete Page, and Clear Page Buttons

New Here ,
Apr 10, 2020 Apr 10, 2020

Copy link to clipboard

Copied

I have a fillable form and have created the three buttons listed in the subject. I am having issues with the Add Page button and Clear Page button working the way I need too.

 

When I click "Add Page"  it creates the new page but it copies all the data from the first page.

JavaScript

car a = this.getTemplate ("Name"); a.spawn();

 

When I click " Clear Page" it clears the entire document not just the page I'm on when I click the button.

JavaScript

if( app.alert({

cMsg: "Are you sure you want to Clear",

cTitle: "Reset Warning",

nIcon: 2,

nType: 2

}) == 4) {

this.resetForm();

}

 

I am basically attempting to add a new page to the document that is the exact same as the first but is blank. I need the buttons to work independently from page to page only affecting the page the button is on. For example if a user needs to start over on page 5 without having to redo pages 1-4 they can click the button and start over. I have no clue what I'm doing any help would be appreciated. 

TOPICS
Acrobat SDK and JavaScript

Views

553

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 ,
Apr 10, 2020 Apr 10, 2020

Copy link to clipboard

Copied

LATEST

Please refer to the reference for the template.spawn() function:

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_Acro...

 

Note the "bRename" input parameter. 

Fields that have the same name have the save value. Id est, if you want unique fields with unique values, they have to be renamed. 

 

Again, for the reset button see the reference for that function. The input argument is an array of  fields to be reset.

Fortunately it works with group naming, so you can use the renamed field prefix to reset all the fields on that page. 

For example:

 

this.resetForm(event.targetName.split(".").shift());

 

This line will reset all renamed fields on a spawned templage page.  It only works for this specific condition. 

 

 

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