Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-5831

Radio button can't be set

    XMLWordPrintableJSON

Details

    Description

      It is impossible to set the upper radio button with this code, the lower is set. With "2" also.

      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");
      

      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.

      Attachments

        1. AU_Erklaerung_final.pdf
          192 kB
          Tilman Hausherr
        2. AU_Erklaerung_final-lower.pdf
          202 kB
          Tilman Hausherr
        3. AU_Erklaerung_final-upper.pdf
          202 kB
          Tilman Hausherr

        Issue Links

          Activity

            People

              msahyoun Maruan Sahyoun
              tilman Tilman Hausherr
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: