On Wed, Feb 24, 2016 at 6:39 PM, Tilman Hausherr <[email protected]> wrote:
> Am 24.02.2016 um 06:21 schrieb David Lattimore: > >> I'm trying to read annotations from PDFs and am having trouble matching up >> replies with the annotations they're in reply to. >> >> PDPage.getAnnotations() returns a list of PDAnnotation. When I have >> a PDAnnotationMarkup, I try to call getInReplyTo to get the previous >> annotation in the thread. But I have two problems: >> >> 1) getInReplyTo() crashes if the annotation isn't a reply. It'd be nice if >> it just returned null. I can work around this by getting the COSDictionary >> and checking for an IRT entry first. >> > > Please post a stack trace java.io.IOException: Error: Unknown annotation type null at org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation.createAnnotation(PDAnnotation.java:167) at org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup.getInReplyTo(PDAnnotationMarkup.java:225) The following code can be used to reproduce this: new PDAnnotationMarkup().getInReplyTo(); > 2) The PDAnnotation returned by getInReplyTo() isn't one of the annotations >> returned by PDPage.getAnnotations() and I can't see how I can match them >> up. Ideally I'd like to get the object ID for each, but the PDAnnotation >> doesn't seem to know it's object ID as far as I can see. I could match >> them >> by keying on various attributes of the annotation like the text content >> and >> the timestamp, but this feels pretty hacky. >> > > try getCOSObject(), this should work. Ah, of course. That does indeed work. Sorry I didn't think of that myself and thank you.

