[
https://issues.apache.org/jira/browse/PDFBOX-4617?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rosalind Douglas updated PDFBOX-4617:
-------------------------------------
Description:
Hello, thank you for all of your efforts in building and maintaining PDFBox. We
use it extensively for parsing PDFs, programmatically setting values and
flattening PDFs for print.
BUG: In the attached PDF, when we try to programmatically set the value of the
radio buttons using PDField.setValue(value), we receive this error:
{code:java}
2019-07-31 08:59:36 ERROR (Prism.java:3744)- STACK:
java.lang.IllegalArgumentException: value '1' is not a valid option for the
field radio1, valid values are: [no, yes] and Off at
org.apache.pdfbox.pdmodel.interactive.form.PDButton.checkValue(PDButton.java:376)
~[pdfbox-2.0.16.jar:2.0.16] at
org.apache.pdfbox.pdmodel.interactive.form.PDButton.setValue(PDButton.java:158)
~[pdfbox-2.0.16.jar:2.0.16]
{code}
The radio buttons all have the same name, and two of them have the same choice
value. We would expect it to behave like Adobe DC, which allows the user to
select any of the buttons regardless of whether they have the same choice or
not. I am on PDFBox 2.0.16.
PROPOSED FIX:
This might be a regression caused by PDFBOX-3391. In our code, we have
overridden the PDButton.setValue method so that it always invokes
updateByValue(value) rather than sometimes using updateByOption(value). Here is
the code that works for us:
{code:java}
@Override public void setValue(String value) throws IOException {
checkValue(value);
updateByValue(value);
applyChange();
}
{code}
was:
Hello, thank you for all of your efforts in building and maintaining PDFBox. We
use it extensively for parsing PDFs, programmatically setting values and
flattening PDFs for print.
BUG: In the attached PDF, when we try to programmatically set the value of the
radio buttons using PDField.setValue(value), we receive this error:
{code:java}
2019-07-31 08:59:36 ERROR (Prism.java:3744)- STACK:
java.lang.IllegalArgumentException: value '1' is not a valid option for the
field radio1, valid values are: [no, yes] and Off at
org.apache.pdfbox.pdmodel.interactive.form.PDButton.checkValue(PDButton.java:376)
~[pdfbox-2.0.16.jar:2.0.16] at
org.apache.pdfbox.pdmodel.interactive.form.PDButton.setValue(PDButton.java:158)
~[pdfbox-2.0.16.jar:2.0.16]
{code}
The radio buttons all have the same name, and two of them have the same choice
value. We would expect it to behave like Adobe DC, which allows the user to
select any of the buttons regardless of whether they have the same choice or
not. I am on PDFBox 2.0.16.
PROPOSED FIX:
This might be a regression caused by PDFBOX-3391. In our code, we have
overridden the PDButton.setValue method so that it always invokes
updateByValue(value) rather than sometimes using updateByOption(value). Here is
your code with the proposed changes:
{code:java}
@Override public void setValue(String value) throws IOException {
checkValue(value);
// if there are export values/an Opt entry there is a different // approach to
setting the value boolean hasExportValues = getExportValues().size() > 0; if
(hasExportValues) { updateByOption(value); } else { updateByValue(value); }
applyChange(); }
{code}
> PDButton.setValue cannot handle radios with duplicate names and choices
> -----------------------------------------------------------------------
>
> Key: PDFBOX-4617
> URL: https://issues.apache.org/jira/browse/PDFBOX-4617
> Project: PDFBox
> Issue Type: Bug
> Components: AcroForm
> Reporter: Rosalind Douglas
> Priority: Major
> Attachments: Radio buttons with duplicate names and choices.pdf
>
>
> Hello, thank you for all of your efforts in building and maintaining PDFBox.
> We use it extensively for parsing PDFs, programmatically setting values and
> flattening PDFs for print.
> BUG: In the attached PDF, when we try to programmatically set the value of
> the radio buttons using PDField.setValue(value), we receive this error:
> {code:java}
> 2019-07-31 08:59:36 ERROR (Prism.java:3744)- STACK:
> java.lang.IllegalArgumentException: value '1' is not a valid option for the
> field radio1, valid values are: [no, yes] and Off at
> org.apache.pdfbox.pdmodel.interactive.form.PDButton.checkValue(PDButton.java:376)
> ~[pdfbox-2.0.16.jar:2.0.16] at
> org.apache.pdfbox.pdmodel.interactive.form.PDButton.setValue(PDButton.java:158)
> ~[pdfbox-2.0.16.jar:2.0.16]
> {code}
> The radio buttons all have the same name, and two of them have the same
> choice value. We would expect it to behave like Adobe DC, which allows the
> user to select any of the buttons regardless of whether they have the same
> choice or not. I am on PDFBox 2.0.16.
> PROPOSED FIX:
> This might be a regression caused by PDFBOX-3391. In our code, we have
> overridden the PDButton.setValue method so that it always invokes
> updateByValue(value) rather than sometimes using updateByOption(value). Here
> is the code that works for us:
> {code:java}
> @Override public void setValue(String value) throws IOException {
> checkValue(value);
> updateByValue(value);
> applyChange();
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]