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

PDPushButton.getOnValues() throws IllegalStateException

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.19, 2.0.20
    • Fix Version/s: 2.0.20, 3.0.0 PDFBox
    • Component/s: AcroForm
    • Labels:
      None
    • Environment:
      Windows 10 (v10.0.18363.778)
      openjdk version "11.0.4" 2019-07-16
      OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11)
      OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode)

      Description

      Calling PDPushButton.getOnValues() results in an IllegalStateException in v2.0.19 and v2.0.20-SNAPSHOT). Not sure if prior versions exhibited this error. Line numbers are identical in both tested versions.  

      java.lang.IllegalStateException: This entry is not an appearance subdictionary
      at org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceEntry.getSubDictionary(PDAppearanceEntry.java:97)
      at org.apache.pdfbox.pdmodel.interactive.form.PDButton.getOnValueForWidget(PDButton.java:349)
      at org.apache.pdfbox.pdmodel.interactive.form.PDButton.getOnValues(PDButton.java:320)
      at AppearanceSubdictionaryError.main(AppearanceSubdictionaryError.java:21)

       

      Sample file attached to issue was created utilizing Adobe Acrobat Standard DC 20.6.20042.

      Sample code to reproduce:

       

      import java.io.File;
      import java.io.IOException;
      import org.apache.pdfbox.pdmodel.PDDocument;
      import org.apache.pdfbox.pdmodel.interactive.form.PDField;
      import org.apache.pdfbox.pdmodel.interactive.form.PDPushButton;
      public class AppearanceSubdictionaryError
      {
          public static void main(String[] args) throws IOException
          {
              PDDocument document = null;
              try
              {
                  document = PDDocument.load(new File("testimage.pdf"));
                  for (PDField field : document.getDocumentCatalog().getAcroForm().getFields())
                  {
                      if (field instanceof PDPushButton)
                      {
                          ((PDPushButton) field).getOnValues();
                      }
                  }
              }
              catch (Exception e)
              {
                  e.printStackTrace();
              }
              finally
              {
                  document.close();
              }
          }
      }
      

       

      Ran across this issue when pulling acro field information from a test document. This doesn't affect our use of the project. I am merely reporting it as it seems like it shouldn't happen.

       

        Attachments

        1. testimage.pdf
          6 kB
          Jay Taylor

          Activity

            People

            • Assignee:
              tilman Tilman Hausherr
              Reporter:
              jay.taylor Jay Taylor
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: