I’m converting dozens of Word documents into PDF forms using Acrobat Pro Version 2024.002.20895. I need all the text input fields in the forms to include some placeholder text that displays with a grey text color. When the user types something into the input, the text color should change back to black.
Each document has between 10 and 50 text input fields so I don’t want to manually add this to each text field (and I don’t want to manually copy a formatted text field to every location).
I’m trying to use Adobe Acrobat’s JavaScript Debugger tool to automate this but need some help.
So far, I’ve written a script that runs in the debugger like so:
var fieldList = this.numFields; //Determine the number of total inputs in document
for (var i = 0; i < this.numFields; i++) { //loop through the number of inputs in document
var field = this.getNthFieldName(i);
var fieldType = getField(field).type;
if (field.type = "text"){ //only modify the text field inputs (ignore the checkboxes and textareas etc.)
//need to add code to modify the text field properties
}
}
The end result is that I need all of the targeted text input fields to have the following properties changed in the entire PDF:
- field.value = “Instructional text goes here”; // Set a value for the field placeholder
- field.textColor = color.ltGray; // Set placeholder color (light grey)
- field.textSize = 10; // Set font size
I also need the text inputs to change from placeholder back to a normal field input when a user activates the field and begins to type a value into it.
I’ve been trying to write an if statement that will only target input fields that have a type = text.
I also, havent been able to successfully modify any of the fields after running the script inside of the debugger.
I’ve tried looking through helpful videos about programming with Adobe Acrobat as well as ChatGPT with not much success for this use case.
If anyone has any suggestions that would be a big help.
lilcoder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.