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

Repopulate PDF Form Fields Down to New Section of Form with Button

New Here ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

At work, for each project I submit, I use a pdf form that has the information from the previous two editions of that project, as well as the current. We manually copy each field down each year (CurrentPages gets copied to PrevPages, etc.). I was hoping I could use javascript and a button to make this automatic. Can anybody help? Some of these fields are text fields, some are drop down lists, etc. Each field that needs populated will already need filled and will need cleared and/or overridden.

TOPICS
Acrobat SDK and JavaScript

Views

271

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

correct answers 1 Correct answer

Community Expert , Jan 09, 2019 Jan 09, 2019

Yes, copying data between field is quite simple, and the type of field doesn't matter.

For your issue, the important thing is that the field names have a predicable and sequential naming convention. Then you can write code that takes advantage of the naming to find and transfer the field data

For example, you could name the fields in the first groupt "1.Text1" "1.Text2" etc. and the fields in the second group "2.Text1" "2.text2" and so on with as many groups as necessary.

This groups the fields usi

...

Votes

Translate

Translate
Community Expert ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

LATEST

Yes, copying data between field is quite simple, and the type of field doesn't matter.

For your issue, the important thing is that the field names have a predicable and sequential naming convention. Then you can write code that takes advantage of the naming to find and transfer the field data

For example, you could name the fields in the first groupt "1.Text1" "1.Text2" etc. and the fields in the second group "2.Text1" "2.text2" and so on with as many groups as necessary.

This groups the fields using a number. Fields in each group have the same name, but with a different group prefix.

This code will transfer the data no matter the field type of number of fields in each group

for(var i=2;i>1;i--)

{

    aFldList = this.getField(i).getArray();

    for(var n=0;n<aFldList.length;n++)

      aFldList.value =  this.getField(aFldList.name.replace(/^\d/,i-1)).value;

}

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