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

Is there a quick way to name the fields?

Contributor ,
Dec 08, 2022 Dec 08, 2022

Hello,

 

When we have hundreds and maybe thousands of fields in a form? Is there a way to name them quickly?

Especially when I want to give the fields specific names, not random ones.
for example:

QDM_S_BE_1

QDM_S_BE_2

QDM_S_BE_3

QDM_S_BE_4

QDM_S_BE_900 ... etc

Is there any trick so save the time?

 

SaherNaji_0-1670538473313.png

 

Thank you

TOPICS
Create PDFs , How to , JavaScript , PDF forms
8.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
2 ACCEPTED SOLUTIONS
Community Expert ,
Dec 08, 2022 Dec 08, 2022

Yes and No.

 

NO, there is no built-in feature for mass naming of fields. I've often thought of writing a plug-in to do this, because I have to do it quite a bit. Although not thousands of fields. Right now you're only option is to do this by hand or write an Acrobat Automation Script to do it. 

 

Yes, there is a way to effectively rename fields with a script. Basically, the script acquires all the properties of a field, deletes  it, then recreates it with a new name.  Not particulary efficient. Of course the difficulty is working out the scheme for attaching a particular field name to a particular field.   But if there are thousands, then it's well worth while to spend the development time.

 

Another solution is to create a spread sheet of the field names, properties, and placement information. Then feed this data into an Acrobat automation script that creates the fields. If names change, then the old fields are deleted and new fields added with the same script. This method works if it is easier to write an Excel macro for creating the field data than it is to write an Acrobat script to add all of the fields from scratch. Plus the spreadsheet is a solid record of the fields.

 

 

    

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

View solution in original post

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 ,
Feb 05, 2025 Feb 05, 2025

"so if i tried to do box.1 - box.2, nothing happened"

You must use:

box\.1 - box\.2

 

"if your first field is named "box", and you create 2 copies, it will rename them "box.1" and "box.2"."

No, they are renamed box.0 and box.1


Acrobate du PDF, InDesigner et Photoshopographe

View solution in original post

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 ,
Dec 08, 2022 Dec 08, 2022

Yes and No.

 

NO, there is no built-in feature for mass naming of fields. I've often thought of writing a plug-in to do this, because I have to do it quite a bit. Although not thousands of fields. Right now you're only option is to do this by hand or write an Acrobat Automation Script to do it. 

 

Yes, there is a way to effectively rename fields with a script. Basically, the script acquires all the properties of a field, deletes  it, then recreates it with a new name.  Not particulary efficient. Of course the difficulty is working out the scheme for attaching a particular field name to a particular field.   But if there are thousands, then it's well worth while to spend the development time.

 

Another solution is to create a spread sheet of the field names, properties, and placement information. Then feed this data into an Acrobat automation script that creates the fields. If names change, then the old fields are deleted and new fields added with the same script. This method works if it is easier to write an Excel macro for creating the field data than it is to write an Acrobat script to add all of the fields from scratch. Plus the spreadsheet is a solid record of the fields.

 

 

    

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

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
Contributor ,
Dec 08, 2022 Dec 08, 2022

Thanks @Thom Parker

Great information.

 

I think creating spreadsheet is a very good solution (with some macros and tricks)

 

Also I will read about writing an Acrobat Automation Script.

 

Thanks again, your reply is amazing

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 ,
Dec 09, 2022 Dec 09, 2022

If you're interested, I've developed several (paid-for) tools that can accomplish it:

https://www.try67.com/tool/easily-rename-pdf-fields

As mentioned, when done in Acrobat the only way to do it is to delete the current fields and then re-create them using the new name. Unfortunately, in doing so all associated scripts are lost, but the properties of the fields can be (mostly) maintained.

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
Contributor ,
Dec 09, 2022 Dec 09, 2022

Hi @try67 

This will be great, Could I use $10 version to name the fields like this: S_1, S_2, S_3, or S.1, S.2, S.3, OR, S1, S2, S3

I mean in this example, could I control the separator? ( _ , . ) 

 

Is there a short video to exaplain how to use it?

 

It will be a great tool, but I have to make sure about how it's working before I purchase

 

Thanks a lot 

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 ,
Dec 09, 2022 Dec 09, 2022

It depends. If the original field names do not have periods in them, then yes. You can specify whatever (new) field name you want. To discuss it further please contact me privately. I'm happy to run the script on a sample file for you and send you back the results, before you purchase it.

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 ,
Dec 09, 2022 Dec 09, 2022

Create the first field with all its options, then right-click : Create multiple copies.

All fields are automatically named.

 

Capture_2211031518.png


Acrobate du PDF, InDesigner et Photoshopographe
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 ,
Dec 09, 2022 Dec 09, 2022

But you can't control how they are named, it's automatic.

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
Contributor ,
Dec 10, 2022 Dec 10, 2022

Thanks @JR Boulay

Great idea to create and arrange fields

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 ,
Dec 06, 2025 Dec 06, 2025
LATEST

JR Boulay... Brilliant! Thank you!

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 ,
Dec 09, 2022 Dec 09, 2022

With practice and a little trickery you can do amazing things.

 

 


Acrobate du PDF, InDesigner et Photoshopographe
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
Contributor ,
Dec 10, 2022 Dec 10, 2022

You're right, but the whole problem was giving (specific names) to hundreds or thousands of fields

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 Beginner ,
Feb 04, 2025 Feb 04, 2025

My problem was a little bit different in that I wanted to change a field name with a "period" to an "underscore", since Adobe seems to struggle to do 'simplified field notation' calculations with fields that were named with a period, but not with an underscore.

so if i tried to do box.1 - box.2, nothing happened, but when renamed to box_1 and box_2, now the formula box_1 - box_2 in 'simplified field notation' works fine.

For some reason when you create multiple text boxes (such as when you right click on one field and then do 'create multiple copies..') it renames each one with a period, so if your first field is named "box", and you create 2 copies, it will rename them "box.1" and "box.2".

On windows, ctrl+J to open the javascript console, clear the console and paste this into the console, (the box one at the bottom). Do ctrl+A to select all of the script that you just pasted, and then ctrl+enter to execute it. It should rename the fields to "box_1" and "box_2" and so on.  Hope this can help someone.

Script:
// Loop backwards so that removal doesn't affect the loop indices
for (var i = this.numFields - 1; i >= 0; i--) {
var origName = this.getNthFieldName(i);
if (origName.indexOf('.') !== -1) {
var newName = origName.replace(/\./g, '_'); // Replace all periods with underscores

// Get the original field
var origField = this.getField(origName);
if (!origField) continue; // safety check

// Create a new field with the same type, page, and rectangle
// Note: You may need to adjust parameters depending on your field type.
var newField = this.addField(newName, origField.type, origField.page, origField.rect);

// Copy basic properties. You may want to copy additional properties as needed.
newField.value = origField.value;
newField.defaultValue = origField.defaultValue;
newField.textSize = origField.textSize;
newField.multiline = origField.multiline;
newField.alignment = origField.alignment;
newField.readonly = origField.readonly;

// Copy any additional properties if needed:
// newField.font = origField.font; etc.

// Remove the original field
this.removeField(origName);

console.println("Renamed field '" + origName + "' to '" + newName + "'");
}
}





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 ,
Feb 04, 2025 Feb 04, 2025

Adobe doesn't struggle with dot naming in simplified field notation.  Let's put that to sleep right away.

If special characters in names are escaped, then there is no problem.

  

 

 

 

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

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 ,
Feb 05, 2025 Feb 05, 2025

"so if i tried to do box.1 - box.2, nothing happened"

You must use:

box\.1 - box\.2

 

"if your first field is named "box", and you create 2 copies, it will rename them "box.1" and "box.2"."

No, they are renamed box.0 and box.1


Acrobate du PDF, InDesigner et Photoshopographe
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 Beginner ,
Feb 06, 2025 Feb 06, 2025

"You must use:

box\.1 - box\.2"

this was the info i needed, thanks!

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 ,
Feb 07, 2025 Feb 07, 2025

Do the same thing in front of blank spaces if there are any in field names.


Acrobate du PDF, InDesigner et Photoshopographe
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