[ 
https://issues.apache.org/jira/browse/PDFBOX-5831?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tilman Hausherr updated PDFBOX-5831:
------------------------------------
    Description: 
It is impossible to set the upper radio button with this code, the lower is 
set. With "2" also.
{code:java}
String filename = "..../AU_Erklaerung_finalAB.pdf";
PDDocument pdfDocument = Loader.loadPDF(new File(filename));
PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm();
acroForm.getField("Formular1[0].Seite1[0].TF_P[0].Optionsfeldliste[0]").setValue("1");
pdfDocument.save(filename + System.currentTimeMillis() + ".pdf");
{code}
Attached: the original file from the user, plus two files where it was set with 
Adobe Reader.

What really happens:

The values from the /Opt entry are 1 and 2, the values at the dictionary level 
are 0 and 1. Our software somehow gets confused when 1 is used because it 
appears in both: when the value "1" is set, then PDButton.updateByOption() is 
called twice (!!!), once with value 1 and once with 2.

The same effect happens with {{setValue(0)}} (integer parameter) if we cast the 
field to a PDRadioButton.

I changed the PDF so that the /Opt entry has "A" and "B" instead of "1" and "2" 
and then it works. (However that can't be changed with Adobe Reader)

The Adobe filled files have 0 and 1 as /V value, we set 1 and 2 as /V value.

  was:
It is impossible to set the upper radio button with this code, the lower is 
set. With "2" also.
{code:java}
String filename = "..../AU_Erklaerung_finalAB.pdf";
PDDocument pdfDocument = Loader.loadPDF(new File(filename));
PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm();
acroForm.getField("Formular1[0].Seite1[0].TF_P[0].Optionsfeldliste[0]").setValue("1");
pdfDocument.save(filename + System.currentTimeMillis() + ".pdf");
{code}
Attached: the original file from the user, plus two files where it was set with 
Adobe Reader.

What really happens:

The values from the /Opt entry are 1 and 2, the values at the dictionary level 
are 0 and 1. Our software somehow gets confused when 1 is used because it 
appears in both: when the value "1" is set, then PDButton.updateByOption() is 
called twice (!!!), once with value 1 and once with 2.

The same effect happens with {{setValue(0)}} if we cast the field to a 
PDRadioButton.

I changed the PDF so that the /Opt entry has "A" and "B" instead of "1" and "2" 
and then it works. (However that can't be changed with Adobe Reader)

The Adobe filled files have 0 and 1 as /V value, we set 1 and 2 as /V value.


> Radio button can't be set
> -------------------------
>
>                 Key: PDFBOX-5831
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5831
>             Project: PDFBox
>          Issue Type: Bug
>          Components: AcroForm
>    Affects Versions: 3.0.2 PDFBox
>            Reporter: Tilman Hausherr
>            Priority: Major
>         Attachments: AU_Erklaerung_final-lower.pdf, 
> AU_Erklaerung_final-upper.pdf, AU_Erklaerung_final.pdf
>
>
> It is impossible to set the upper radio button with this code, the lower is 
> set. With "2" also.
> {code:java}
> String filename = "..../AU_Erklaerung_finalAB.pdf";
> PDDocument pdfDocument = Loader.loadPDF(new File(filename));
> PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm();
> acroForm.getField("Formular1[0].Seite1[0].TF_P[0].Optionsfeldliste[0]").setValue("1");
> pdfDocument.save(filename + System.currentTimeMillis() + ".pdf");
> {code}
> Attached: the original file from the user, plus two files where it was set 
> with Adobe Reader.
> What really happens:
> The values from the /Opt entry are 1 and 2, the values at the dictionary 
> level are 0 and 1. Our software somehow gets confused when 1 is used because 
> it appears in both: when the value "1" is set, then PDButton.updateByOption() 
> is called twice (!!!), once with value 1 and once with 2.
> The same effect happens with {{setValue(0)}} (integer parameter) if we cast 
> the field to a PDRadioButton.
> I changed the PDF so that the /Opt entry has "A" and "B" instead of "1" and 
> "2" and then it works. (However that can't be changed with Adobe Reader)
> The Adobe filled files have 0 and 1 as /V value, we set 1 and 2 as /V value.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to