使用JavaScript遍历PDF表单中的所有字段 [英] Iterating over all fields in a PDF form with JavaScript

查看:275
本文介绍了使用JavaScript遍历PDF表单中的所有字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想响应用户单击按钮来修改PDF表单中所有字段的某些属性.

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?

推荐答案

如果有字段的集合,我仍然没有找到它.不过,有一种方法可以遍历所有字段.

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

doc对象的numFields属性给出了字段数, getNthFieldName(index)返回具有该索引的字段的名称,而getField( fieldName )返回该名称的字段.

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

这篇关于使用JavaScript遍历PDF表单中的所有字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆