[
https://issues.apache.org/jira/browse/PDFBOX-3401?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15410637#comment-15410637
]
Tilman Hausherr edited comment on PDFBOX-3401 at 8/6/16 3:36 PM:
-----------------------------------------------------------------
While I still think that my fix is correct, there is something else that
doesn't work at all. I used the code below to test my change but I didn't go
very far:
{code}
try (PDDocument doc = PDDocument.load(new File("000671.pdf")))
{
PDStructureTreeRoot structureTreeRoot =
doc.getDocumentCatalog().getStructureTreeRoot();
PDNumberTreeNode parentTree = structureTreeRoot.getParentTree();
for (PDNumberTreeNode ntn : parentTree.getKids())
{
Map<Integer, COSObjectable> numbers = ntn.getNumbers();
System.out.println(numbers);
}
}
Exception in thread "main" java.io.IOException: Error while trying to create
value in number
tree:org.apache.pdfbox.cos.COSBase.<init>(org.apache.pdfbox.cos.COSArray)
at
org.apache.pdfbox.pdmodel.common.PDNumberTreeNode.convertCOSToPD(PDNumberTreeNode.java:218)
at
org.apache.pdfbox.pdmodel.common.PDNumberTreeNode.getNumbers(PDNumberTreeNode.java:189)
at pdfboxpageimageextraction.PDFBox3401.main(PDFBox3401.java:31)
Caused by: java.lang.NoSuchMethodException:
org.apache.pdfbox.cos.COSBase.<init>(org.apache.pdfbox.cos.COSArray)
at java.lang.Class.getConstructor0(Class.java:2892)
at java.lang.Class.getConstructor(Class.java:1723)
at
org.apache.pdfbox.pdmodel.common.PDNumberTreeNode.convertCOSToPD(PDNumberTreeNode.java:212)
... 2 more
{code}
PDNumberTreeNode.convertCOSToPD() expects the valueType (here: COSBase) to have
a constructor that accepts a COSArray as parameter. COSBase does not have any
constructor with parameters.
was (Author: tilman):
While I still think that my fix is correct, there is something else that
doesn't work at all. I used the code below to test my change but I didn't go
very far:
{code}
try (PDDocument doc = PDDocument.load(new File("000671.pdf")))
{
PDStructureTreeRoot structureTreeRoot =
doc.getDocumentCatalog().getStructureTreeRoot();
PDNumberTreeNode parentTree = structureTreeRoot.getParentTree();
for (PDNumberTreeNode ntn : parentTree.getKids())
{
Map<Integer, COSObjectable> numbers = ntn.getNumbers();
System.out.println(numbers);
}
}
Exception in thread "main" java.io.IOException: Error while trying to create
value in number
tree:org.apache.pdfbox.cos.COSBase.<init>(org.apache.pdfbox.cos.COSArray)
at
org.apache.pdfbox.pdmodel.common.PDNumberTreeNode.convertCOSToPD(PDNumberTreeNode.java:218)
at
org.apache.pdfbox.pdmodel.common.PDNumberTreeNode.getNumbers(PDNumberTreeNode.java:189)
at pdfboxpageimageextraction.PDFBox3401.main(PDFBox3401.java:31)
Caused by: java.lang.NoSuchMethodException:
org.apache.pdfbox.cos.COSBase.<init>(org.apache.pdfbox.cos.COSArray)
at java.lang.Class.getConstructor0(Class.java:2892)
at java.lang.Class.getConstructor(Class.java:1723)
at
org.apache.pdfbox.pdmodel.common.PDNumberTreeNode.convertCOSToPD(PDNumberTreeNode.java:212)
... 2 more
{code}
PDNumberTreeNode.convertCOSToPD() expects the valueType (here: COSBase) to have
a constructor that accepts a COSArray as parameter. COSBase does not have any
constructor.
> PDObjectReference getReferencedObject() returns null is referenced obj is not
> a COSStream
> -----------------------------------------------------------------------------------------
>
> Key: PDFBOX-3401
> URL: https://issues.apache.org/jira/browse/PDFBOX-3401
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 1.8.9, 2.0.2, 2.0.3, 2.1.0
> Reporter: Mark Melling
>
> When creating a pdf I am setting a PDAnnotation as the referenced object of a
> PDObjectReference using setReferencedObject.
> When I subsequently load the same document and then call getReferencedObject
> on the PDObjectReference, null is returned. This is because an exception is
> thrown in PDXObject.createXObject (called inside getReferencedObject) as the
> referenced object is not a COSStream, just a COSDictionary.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]