Loop Through Fields
Copy link to clipboard
Copied
Can someone help me come up with a console code that prints the name of each field? I had it just hours ago, and I cannot locate it again, nor come up with it on my own.
Copy link to clipboard
Copied
In the Acrobat Javascript Reference look at the method getNthFieldName
Copy link to clipboard
Copied
Right. So I need help fixing this:
for(var i = 0; i < this.numFields; i++){
console.println(i + ": " + this.getNthFieldName(i));
}
Copy link to clipboard
Copied
Or even directly from the JS Ref:
for (var i = 0; i < this.numFields; i++)
console.println("Field[" + i + "] = " + this.getNthFieldName(i));
I think I don't understand console exactly right. I put that in, highlight it all, and hit ctrl+enter. I get undefined.
Copy link to clipboard
Copied
Did you open a document with form fields?
Copy link to clipboard
Copied
I want to see a list of field names and their index numbers. A loop similar to this one was printing 31 lines of field names for me earlier, but I can't replicate it or find it again.
Copy link to clipboard
Copied
The code above should work. Make sure you select all of it before pressing Ctrl+Enter, though.
Copy link to clipboard
Copied
You'll find a free tool here called "Find Required Fields". It loops through all the fields on a form and displays the ones that are required in a dropdown menu. It can easily be modified to show fields with any characteristic, or all of them.
https://www.pdfscripting.com/public/Free_Acrobat_Automation_Tools.cfm
Use the Acrobat JavaScript Reference early and often

