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.

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.

I'd be interested to know if there are other places in PDFs where an object
can be referenced from multiple locations in the document and where the
identity of that object is important.

How hard do you think it would be to make objects know their object number
once they're dereferenced? Or perhaps there's another way to deal with this?

Thanks,
David

Reply via email to