Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Iterating over all fields in a PDF form with JavaScript

I would like to modify some properties for all fields in a PDF form in response to the user clicking a button.

Which property or method will return me the collection of fields so that I can iterate over them?

like image 707
Bell Avatar asked Aug 31 '10 17:08

Bell


1 Answers

If there is a collection of fields I still haven't found it. There is a way to iterate over all the fields though.

The numFields property of the doc object gives the number of fields, getNthFieldName(index) returns the name of the field with that index and getField(fieldName) returns the field of that name.

for (var fieldNumber = 0; fieldNumber < numFields; fieldNumber ++)
{
  getField(getNthFieldName(fieldNumber)).value = 'Scripty Was Here';
}
like image 92
Bell Avatar answered Oct 08 '22 10:10

Bell