如何确定复选框的“已检查”值(来自GetAppearanceStates) [英] How to determine “Checked” value for Checkboxes (from GetAppearanceStates)

查看:135
本文介绍了如何确定复选框的“已检查”值(来自GetAppearanceStates)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对复选框字段有疑问,始终确定用于检查状态的值。

I have a question about checkbox fields, and consistently figuring out which value to use for a checked state.

我一直在搜索并且为iText in Action手册支付了50美元并且还搜索了它。这本书很棒,但它没有回答这个特定问题。

I have been searching, and shelled out $50 for the iText in Action book and scoured it as well. The book is great, but it didn’t answer this particular question.

我知道调用GetAppearanceStates(fieldName)来获取特定字段的可能值的域,并且知道调用SetField(fieldName,value)来检查框。

I know to call GetAppearanceStates(fieldName) to get the domain of possible values for a particular field, and know to call SetField(fieldName, value) to check the box.

我的问题是:我如何明确地知道值的哪一个GetAppearanceStates返回的是Check值,还是我需要用来检查字段的值?

My question is: how do I definitively know WHICH of the values returned by GetAppearanceStates is the "Check" value, or the value I need to use to check the field?

公平地说,我见过的大多数表单使用的值都是:真,假,开,关,是,否......但如果我理解正确,PDF的创建者可以指定任意值。

To be fair, most forms I've seen use values like: True,False,On,Off,Yes,No... but if I understand things correctly, the creator of the PDF can specify any arbitrary value.

是否有一种方法可以确定,GetAppearanceStates返回的值的哪一个是检查值?

Is there a way to find out, for sure, WHICH of the values returned by GetAppearanceStates is the "check" value?

我看到的例子似乎表明了第一个元素数组将是检查它的那个,但显然这只是我在这个例子中读得太多,因为我遇到了一个文件w这里第一个元素是关闭(第二个元素是是)。在我深入研究并编写显式查找字符串值的代码之前,如True,Yes,On,Oui,Yuppers,Check ......或其他什么,我想我会看到是否有更好的方法!我真的希望我错过了一些东西。

The examples I saw seemed to indicate the first element in the array would be the one to check it, but apparently that was just me reading too much into the example, because I’ve run into a document where the first element is "Off" (and the second is "Yes"). Before I dive in and write code that explicitly looks for string values like True,Yes,On,Oui,Yuppers,Check… or whatever, I thought I’d see if there is a better way! I really hope I’m missing something.

同样,我只在这里使用复选框字段。

Again, I'm working only with checkbox fields here.

感谢您的任何帮助!

推荐答案

ISO 32000-1:2008(PDF 1.7 spec)在12.7中说。 4.2.3(复选框):

ISO 32000-1:2008 ("PDF 1.7 spec") says in 12.7.4.2.3 ("Check Boxes"):


关闭状态的外观是可选的,但如果存在,则为
以名称关闭存储在外观字典中。
应该用作开启状态的名称。

The appearance for the off state is optional but, if present, shall be stored in the appearance dictionary under the name Off. Yes should be used as the name for the on state.

所以如果有的话未经检查状态的外观,必须关闭。选中状态的是建议;它的名称可以不同。

So if there's an appearance for the unchecked state, it has to be Off. The Yes for the checked state is a recommendation; it can be named differently.

如果2个任意名称用于选中和未选中,则无法可靠地确定哪个应该用于检查,哪个用于未选中。

If 2 arbitrary names are used for checked and unchecked, you can't reliably determine which should be used for checked and which for unchecked.

这篇关于如何确定复选框的“已检查”值(来自GetAppearanceStates)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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