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

Auto-create fields with same name using javascript

New Here ,
Dec 31, 2021 Dec 31, 2021

I am trying to run the following script as a Custom Command. My delimma is that only the first field is being generated. Two of my fields MUST have the same name due to an integration with another software platform. How do I get around this?

var sf = this.addField("Field_Name[0]", "signature", 0, [223,554,279,540]);

var sf = this.addField("Field_Name[0]", "signature", 0, [332,38,388,24]);

 

I seem to be able to create them manually just fine and Acrobat automatically differntiates both fields:

kautzklara_0-1641005045839.pngexpand image

If I open Properties for both of the above fields, the name is indeed identical for both - Acrobat is not appending the #1 to the actual field name. I attached what I am talking about below: Sample.pdf

 

How do I achieve this same end using javascript?

 

Thanks in advance for the help and Happy New Year!

 

TOPICS
General troubleshooting , How to , JavaScript , PDF forms
1.0K
Translate
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 ,
Jan 01, 2022 Jan 01, 2022

The "#1" part is not a part of the actual field name. It's how the user interface in Acrobat shows that the two fields share the same name, but are unique widgets, with the number being the index number of that widget in the field group. It should appear exactly the same, regardless of how the fields are created.

Translate
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
New Here ,
Jan 02, 2022 Jan 02, 2022

Thank you for your response. Yes, I understand that that is the effect when creating the fields manually. The question at hand is how to recreate that using javascript? The sample code above only results in one field being created rather than both. For some reason, Acrobat seems to ignore the second line of code and does not simply create a second field with the '#1' as Acrobat does when the fields are created manaually.

Translate
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 ,
Jan 02, 2022 Jan 02, 2022

You can't create two signature fields with the same name.

Translate
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 ,
Jan 02, 2022 Jan 02, 2022
LATEST

Note that when you did it manually you created text fields. If you tried to do the same with signature fields, it won't work, either.

Translate
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