[
https://issues.apache.org/jira/browse/PDFBOX-3656?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15862445#comment-15862445
]
Maruan Sahyoun commented on PDFBOX-3656:
----------------------------------------
Situation with your form [^test.pdf]:
The radio button has 3 parts {{a}},{{b}},{{c}} with the normal appearance
entries for the {{On}} state being named {{a}}, {{b}} and {{c}}. So if you set
a value of a there is also a corresponding normal appearance entry for the
{{On}} state. Now the value {{/V}} should be {{a}} if the first option is
checked, {{b}} for the second and {{c}} for the third. There is no benefit
having an {{/Opts}} entry as the value you'd like for the field can be
represented as a name and is also similar to the normal appearance entries
name. With the {{/Opts}} entry mapping {{a}} to {{0}}, {{b}} to {{1}} and {{c}}
to {{2}} when you set the value to {{c}} the {{/V}} entry will be {{2}} which
is not represented by a normal appearance entry which is the reason why you
won't see the option being checked after you opened the file in Acrobat.
*This is a bug in our current code!*
Situation with [^SF1199AEG (Complete).pdf]:
The {{On}} state for the options has a COSName of {{0}}, {{1}}, {{2}}, .....
which means the the value {{/V}} should represent that. So in case the first
option is checked {{/V}} has a value of {{0}}. The {{/Opts}} entry now states
that having checked the first option this should be treated (exported) as
{{Checking}}. e.g. when you export the form data using Adobe Acrobat
{{Checking}} is exported and not {{0}}.
So the {{/Opts}} entry is relevant when the data is exported. To set the value
the {{/V}} entry should correspond to a normal appearance entry. Now when the
data is imported (e.g. FDF import) again the {{/Opts}} entry is relevant to map
from the data in the data file to the appearance entry name in the PDF and the
{{/V}} entry.
I'll go and change that so that (for your form) you need to set using a,b,c and
you'll get a,b,c. For the other form you'll need to set 0,1,2,... and you'll
get 0,1,2,3. {{getExportValue}} will give you Checking or Saving and a,b,c. The
new method {{setByExportValue}} will allow to use the export value to set the
field value and shall be used for our FDF import.
Hope that's better now although a lot of text :-)
> Problem when setting COSName.Off on radio button
> ------------------------------------------------
>
> Key: PDFBOX-3656
> URL: https://issues.apache.org/jira/browse/PDFBOX-3656
> Project: PDFBox
> Issue Type: Bug
> Components: AcroForm
> Affects Versions: 2.0.3, 2.0.4
> Reporter: Scott Coldwell
> Assignee: Maruan Sahyoun
> Fix For: 2.0.5, 2.1.0
>
> Attachments: SF1199AEG (Complete).pdf, test.pdf
>
>
> The following error occurs when trying to set the radio button to COSName.Off
> when the field contains /Opt values:
> {code}
> ERROR (PDFDocument.java:98) - Error populating form us/gov/opm/SF2817
> java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.elementData(ArrayList.java:418) ~[na:1.8.0_45]
> at java.util.ArrayList.get(ArrayList.java:431) ~[na:1.8.0_45]
> at
> org.apache.pdfbox.pdmodel.common.COSArrayList.get(COSArrayList.java:544)
> ~[pdfbox-2.0.3.jar:2.0.3]
> at
> org.apache.pdfbox.pdmodel.interactive.form.PDButton.constructAppearances(PDButton.java:275)
> ~[pdfbox-2.0.3.jar:2.0.3]
> at
> org.apache.pdfbox.pdmodel.interactive.form.PDTerminalField.applyChange(PDTerminalField.java:228)
> ~[pdfbox-2.0.3.jar:2.0.3]
> at
> org.apache.pdfbox.pdmodel.interactive.form.PDButton.setValue(PDButton.java:167)
> ~[pdfbox-2.0.3.jar:2.0.3]
> {code}
> the code that triggers the error is:
> {code}
> field.setValue(COSName.Off.getName());
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]