Skip to main content
JMFreeman
Inspiring
Jan 15, 2020 8:15 PM UTC
Question

Loop Through Fields

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.

This topic is closed to new replies. Start a new post to keep the conversation going.

7 replies

Thom Parker
Community Expert
Community Expert
Jan 16, 2020 7:38 AM UTC

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

 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Bernd Alheit
Community Expert
Community Expert
Jan 15, 2020 8:26 PM UTC

In the Acrobat Javascript Reference look at the method getNthFieldName

 

Translate
JMFreeman
JMFreemanAuthor
Inspiring
Jan 15, 2020 8:27 PM UTC

Right. So I need help fixing this:

for(var i = 0; i < this.numFields; i++){
console.println(i + ": " + this.getNthFieldName(i));
}
Translate
JMFreeman
JMFreemanAuthor
Inspiring
Jan 15, 2020 8:29 PM UTC

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.

Translate