Skip to main content
JMFreeman
Inspiring
January 15, 2020
Question

Loop Through Fields

  • January 15, 2020
  • 2 replies
  • 3832 views

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 has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
January 16, 2020

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

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Bernd Alheit
Community Expert
Community Expert
January 15, 2020

In the Acrobat Javascript Reference look at the method getNthFieldName

 

JMFreeman
JMFreemanAuthor
Inspiring
January 15, 2020

Right. So I need help fixing this:

for(var i = 0; i < this.numFields; i++){
console.println(i + ": " + this.getNthFieldName(i));
}
JMFreeman
JMFreemanAuthor
Inspiring
January 15, 2020

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.