Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is it possible get pdf object id/number from selection?

533 views
Skip to first unread message

dodjavo...@gmail.com

unread,
Jan 15, 2015, 1:32:26 PM1/15/15
to mozilla-d...@lists.mozilla.org
Hello everyone,

I am working on annotation system for PDF.js. So far I was able to add annotation using coordinates from user's selection, and binding annotation to those coordinates, but I am wondering, is it possible somehow to get PDF object ID (COS Object), using those coordinates?
I need to bind annotation to object ID also, just in case document changes, and position of that particular object changes.
Also, if you have any better approach for adding annotations, I am all in ears :) I started looking into annotator.js

Thanks in advance!

Leonard Rosenthol

unread,
Jan 15, 2015, 3:51:32 PM1/15/15
to dodjavo...@gmail.com, mozilla-d...@lists.mozilla.org
On 1/15/15, 5:40 PM, "dodjavo...@gmail.com" <dodjavo...@gmail.com>
wrote:



>I am working on annotation system for PDF.js. So far I was able to add
>annotation using coordinates from user's selection, and binding
>annotation to those coordinates, but I am wondering, is it possible
>somehow to get PDF object ID (COS Object), using those coordinates?

PDF graphic elements aren’t CosObjects - they are a completely different
type of beast.

Existing annotations, of course, would be CosObjects - but I don’t think
that’s what you mean.


>I need to bind annotation to object ID also, just in case document
>changes, and position of that particular object changes.

If you need that, then you will need to ensure that you are working with a
tagged PDF contain PDF structure, since that is the model in PDF for
binding annotations to graphic elements. And since only about 10% of all
PDFs are tagged - that may be a problem.


Leonard
PDF Architect · Principal Scientist | Adobe Systems Incorporated | p.
408.657.PDFS | c. 215.808.4978 | leon...@adobe.com





dodjavo...@gmail.com

unread,
Jan 16, 2015, 11:02:46 AM1/16/15
to mozilla-d...@lists.mozilla.org
Thanks for quick replay.

I guess that I misunderstood PDF structure than. I thought that whole PDF is made of objects. Those objects could be text, images, etc... Am I wrong?

If I am, is there any way to bind some annotation to specific, highlighted text, so that annotation will move, if position of that text changes?

Leonard Rosenthol

unread,
Jan 16, 2015, 4:11:25 PM1/16/15
to dodjavo...@gmail.com, mozilla-d...@lists.mozilla.org
On 1/15/15, 9:05 PM, "dodjavo...@gmail.com" <dodjavo...@gmail.com>
wrote:



>I guess that I misunderstood PDF structure than. I thought that whole PDF
>is made of objects. Those objects could be text, images, etc... Am I
>wrong?

The “body” of a PDF is made up of objects, but graphic elements (text,
images, etc.) are actually “sub-objects” to a higher order object called a
Content Stream.

This is all described in ISO 32000-1:2008 (aka the PDF standard) or in my
book (<http://shop.oreilly.com/product/0636920025269.do>).


>If I am, is there any way to bind some annotation to specific,
>highlighted text, so that annotation will move, if position of that text
>changes?
>

Yes and no.

You can bind an annotation to a specific set of graphic elements using the
“tagging” features of PDF. However, because the annotation has a
bounding box representing where it appears visually on the page, it won’t
“automatically travel” with the text when edited. (of course, a smart PDF
editor might certainly do that - but it’s not necessary a requirement)

Leonard

chit...@gmail.com

unread,
Apr 14, 2015, 10:14:47 AM4/14/15
to mozilla-d...@lists.mozilla.org
when you create annotations you should also add a property of the pagenumber so you can keep track of it

each page is enclosed with id of pageContainer#

you can parse that to get the page numbet
0 new messages