找出必填字段填写PDF文件 [英] finding out required fields to fill in pdf file

查看:642
本文介绍了找出必填字段填写PDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在我的Andr​​oid应用程序的新功能,这将有助于填补某些PDF表单。

I'm starting with new functionality in my android application which will help to fill certain PDF forms.

我找出最好的解决方案将使用iText库。

I find out that the best solution will be to use iText library.

我可以读文件,然后从文件中读取AcroFields但是否有可能找出所需的特定字段被标记?

I can read file, and read AcroFields from document but is there any possibility to find out that specific field is marked as required?

我试图找到这个选项的API文档,并在互联网上,但有什么可以帮助解决这个问题。

I tried to find this option in API documentation and on Internet but there were nothing which can help to solve this issue.

推荐答案

请看看我的书,题为AcroForms再访。清单13.15展示了从检查是否在 InspectForm 例如code片段不是一个场是一个密码或一个多行字段

Please take a look at section 13.3.4 of my book, entitled "AcroForms revisited". Listing 13.15 shows a code snippet from the InspectForm example that checks whether or not a field is a password or a multi-line field.

通过一些小的改动,可以适应这个例子检查必填字段:

With some minor changes, you can adapt that example to check for required fields:

for (Map.Entry<String,AcroFields.Item> entry : fields.entrySet()) {
    out.write(entry.getKey());
    item = entry.getValue();
    dict = item.getMerged(0);
    flags = dict.getAsNumber(PdfName.FF);
    if (flags != null && (flags.intValue() & BaseField.REQUIRED) > 0)
        out.write(" -> required\n");
}

这篇关于找出必填字段填写PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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