Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.0.19, 2.0.20
-
None
-
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.