Am 05.02.2016 um 06:27 schrieb David Lattimore:
I'm attempting to upgrade an application from PDFBox 1.8.7 to
2.0.0-RC3. The following code works with the former but crashes with
the latter:
PDDocument document = PDDocument.load(new
File("/path/to/existing_js.pdf"));
document.getDocumentCatalog().getNames().getJavaScript().getNames();
The crash is as follows:
java.io.IOException: Error creating Javascript object, expected a
COSDictionary and not COSString{console.println("Hello console!");}
at
org.apache.pdfbox.pdmodel.PDJavascriptNameTreeNode.convertCOSToPD(PDJavascriptNameTreeNode.java:56)
at
org.apache.pdfbox.pdmodel.PDJavascriptNameTreeNode.convertCOSToPD(PDJavascriptNameTreeNode.java:1)
at
org.apache.pdfbox.pdmodel.common.PDNameTreeNode.getNames(PDNameTreeNode.java:261)
I had a look at some correct files. Please use PDFDebugger, switch to
"show internal structure" and enter this:
Root/Names/JavaScript/Names/[0]
JavaScript is "A name tree mapping name strings to document-level
JavaScript actions" (p. 81 of the 32000 spec)
Names is an array: [key1 value1 key2 value2 … keyn valuen] (p. 89 of
the 32000 spec)
"JavaScript Actions" are explained on p. 430 - these are dictionaries
with two entries, S and JS. Seems that your file has only a string.
Tilman
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]