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

PDButton.getOnValues seems to be using the wrong source for getting the allowed values

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.3, 3.0.0 PDFBox
    • Component/s: AcroForm
    • Labels:
      None

      Description

      We are in the process of migrating from itext to pdfbox and noticed that an exception was being thrown when trying to set a radio button with PDField.setValue(). The values returned from PDButton.getOnValues() which is used by PDButton.checkValue() called from PDButton.setValue() are only returning 0,1 instead of what we had been using with itext. After investigating itext's source code and playing around with pdfbox I was able to get to what I believe are the appropriate allowed values by using the following code.

              if (field instanceof PDButton)
              {
                  final COSBase item = field.getCOSObject().getItem(COSName.OPT);
                  if (item != null && item instanceof COSArray)
                  {
                      final COSArray optArray = (COSArray)item;
      
                      for (int i = 0 ; i < optArray.size() ; i++)
                      {
                          // Each item in this array is an allowed value
                          // optArray.getString(i);
                      }
                  }
              }
      

        Attachments

        1. SF2817.pdf
          317 kB
          Scott Coldwell
        2. SF1199AEG (Complete).pdf
          77 kB
          Scott Coldwell
        3. SF2817.pdf
          482 kB
          Scott Coldwell

          Activity

            People

            • Assignee:
              msahyoun Maruan Sahyoun
              Reporter:
              scoldwell Scott Coldwell
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: