Copy link to clipboard
Copied
Hi everyone,
I have a PDF with multiple form fields, some of which have spaces in their names (e.g., Text Field 1). I want to rename them to remove spaces (e.g., TextField1).
I tried using Acrobat Javascript:
for (var i = 0; i < this.numFields; i++) {
var oldName = this.getNthFieldName(i);
var newName = oldName.replace(/\s+/g, "");
this.renameField(oldName, newName); // Throws TypeError
}
…but I get this error:
TypeError: this.renameField is not a function
Copy link to clipboard
Copied
"renameField" is not a function.
A field cannot be renamed directly. You must save its properties, delete the existing field, and recreate another one in the same place.
The disadvantage is that the field's actions, format, etc. are lost during this process.
You should use this script: https://vielhuber.de/en/blog/rename-pdf-form-fields-en-masse/
Copy link to clipboard
Copied
"renameField" is not a function.
A field cannot be renamed directly. You must save its properties, delete the existing field, and recreate another one in the same place.
The disadvantage is that the field's actions, format, etc. are lost during this process.
You should use this script: https://vielhuber.de/en/blog/rename-pdf-form-fields-en-masse/
Copy link to clipboard
Copied
Thank you very much @JR Boulay
Find more inspiration, events, and resources on the new Adobe Community
Explore Now