Christian Appl created PDFBOX-5546:
--------------------------------------

             Summary: Issue with the index based RadioButton value selection.
                 Key: PDFBOX-5546
                 URL: https://issues.apache.org/jira/browse/PDFBOX-5546
             Project: PDFBox
          Issue Type: Bug
          Components: AcroForm
    Affects Versions: 2.0.27
            Reporter: Christian Appl
         Attachments: WEBPDF-1616.patch

We encountered an issue with the index based selection of RadioButton values - 
in case an "Opt" Array (Export value) definition is present.

*The issue: valid index selections are overwritten, when calling 
"constructAppearances()"*
Location: 
{color:#000000}org.apache.pdfbox.pdmodel.interactive.form.PDButton{color}:
When selecting an option via index - with activated "generateAppearances" flag 
- via "setValue(int)": The value (V) of the RadioButton field and the 
appearance states of it´s contained streams were updated accordingly and 
correctly. 
But when debugging I found that the following internal call to: 
applyChanges->constructAppearances, would override the correct values with 
erroneous ones that rather match the direct onState selection (without Opt 
array).

Which lead to me implementing the hereby provided patch trying to address the 
issue.

*Additonal observation: onValue name and index mismatch*
When setting the Value V of the containing RadioButton field the current 
implementation assumed, that the name of the "onState" Stream would always 
match the index of the child in the kids/Opt array.
I was able to create a document (using Adobe DC) that did contradict that 
assumption. Adobe DC allows selecting custom names for the Acroform "onState" 
names (and streams) in that case the index of the child may i.e. be 0, while 
the name of the "onState" stream is "Choice1", but using "Choice1" as the "V" 
value for the field will not lead to a valid/working result.
In this patch you will also find a solution, that attempts to address that 
issue aswell.

*Tests:*
You will also find two tests in the patch, that summarize the behaviour I would 
assume to be correct.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to