Iterating over all fields in a PDF form with JavaScript

▼魔方 西西 提交于 2019-12-10 13:26:19

问题


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?


回答1:


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';
}


来源:https://stackoverflow.com/questions/3611445/iterating-over-all-fields-in-a-pdf-form-with-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!