gpt4 book ai didi

multi-select - PDF 中的多选表单域

转载 作者:行者123 更新时间:2023-12-04 04:40:20 25 4
gpt4 key购买 nike

使用 PDF,是否可以创建具有多个字段且可以选择多个字段的单个表单元素?例如,在 HTML 中,可以创建一组与相同字段名称关联的复选框:

<div>Select one for Member of the School Board</div>
<input type="checkbox" name="field(school)" value="vote1">
<span class="label">Libby T. Garvey</span><br/>
<input type="checkbox" name="field(school)" value="vote2">
<span class="label">Emma N. Violand-Sanchez</span><br/>

在这种情况下,字段名称是“field(school)”,提交表单时,“field(school)”可以提供 0 次、1 次或 2 次。

在 PDF 中是否有一个等效的结构,其中单个字段可以有多个值。到目前为止,在我的调查中,似乎如果为字段分配了相同的名称,则只能选择一个字段。如果可以在 PDF 中实现这一点,那么这个构造称为什么以及如何实现?

编辑:澄清一下,我知道 PDF 可以包含多个具有不同字段名称的表单字段,并且可以独立选择这些字段,但是分组是隐式的,而不是像 HTML 表单那样显式的。我想使用一种使选项分组明确的构造,并且最好允许限制(例如,至少需要一个,允许不超过 2 个,等等)。

编辑:如果有人能找到权威意见认为这是不可能的,那也是一个可取的答案。

最佳答案

是的,这是可能的。在 Adob​​e PDF 中,您有复选框概念和单选按钮概念。虽然每个复选框和单选按钮都可以有自己的名称,但是,它们也可以通过 GroupName.subobj 通过子层进行分组。

Adobe 是这样描述的:

The field name. This may includehierarchical syntax in order tofacilitate logical groupings. Forexample, the name myGroup.firstFieldimplies that the form field firstFieldbelongs to a group of fields calledmyGroup. The advantage of creatinglogical hierarchies is that you canenforce consistency among theproperties of related form fields bysetting the properties of the group,which automatically propagate to allform fields within the group.

当通过层次结构设置字段时,您可以在这种情况下获取 myGroup 的值,并返回组的选定值。同样,对于单选按钮,您需要确保组中的所有字段都具有相同的名称。

This approach to creating form fieldsis applicable to all fields, but itshould be noted that radio buttonsrequire special treatment. Since a setof radio buttons represents a set ofmutually exclusive choices, theybelong to the same group. Because ofthis, the names of all radio buttonsin the same group must be identical.In addition, the export values of the

set of radio buttons must be set witha single statement, in which an arrayof values are assigned by theexportValues property of the Fieldobject. For example, suppose we wouldlike to create a set of three radiobuttons, each 12 points wide and 12points high, all named myRadio. Wewill place them on page 5 of thedocument, and their export values willbe Yes, No, and Cancel. They can becreated as shown in the code givenbelow:

var name = "myRadio";
var type = "radiobutton";
var page = 5;
var rb = this.addField(name, type, page, [400, 442, 412, 430]);
this.addField(name, type, page, [400, 427, 412, 415]);
this.addField(name, type, page, [400, 412, 412, 400]);
rb.exportValues=["Yes", "No", "Cancel"];

关于multi-select - PDF 中的多选表单域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2561686/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com