Copy link to clipboard
Copied
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?
Thank you
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
"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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Create the first field with all its options, then right-click : Create multiple copies.
All fields are automatically named.
Copy link to clipboard
Copied
But you can't control how they are named, it's automatic.
Copy link to clipboard
Copied
Thanks @JR Boulay
Great idea to create and arrange fields
Copy link to clipboard
Copied
JR Boulay... Brilliant! Thank you!
Copy link to clipboard
Copied
With practice and a little trickery you can do amazing things.
Copy link to clipboard
Copied
You're right, but the whole problem was giving (specific names) to hundreds or thousands of fields
Copy link to clipboard
Copied
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 + "'");
}
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
"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
Copy link to clipboard
Copied
"You must use:
box\.1 - box\.2"
this was the info i needed, thanks!
Copy link to clipboard
Copied
Do the same thing in front of blank spaces if there are any in field names.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more