How to get the parent annotation when adding a note to an annotation?

17 views
Skip to first unread message

Ryan - PDFNet Developer

unread,
Nov 8, 2016, 2:16:56 PM11/8/16
to PDFTron WebViewer
Question:

Our use case is as below:
 
1.       We first create an annotation on PDF (This can be any annotation, rectangle or polygon).
2.       Then we create a sticky note annotation, by selecting the annotation and choosing "Create Note" on this previously created annotation in step 1.
3.       Now, while creating this sticky note annotation(in step 2), we need to get the annotation(i.e. created in step 1) on which current sticky note annotation is getting created.

Answer:

When you add a note to an annotation, like a Rectangle annotation, this text is added as the Contents attribute of the original annotation, and not a separate StickyNote annotation. (though they certainly look the same).

In WebViewer the note and the original annotation are one and the same javascript object.

For example if you call the following before and after step 1, you will see the annotation size increase by 1. If you then call it after step 2, you will see that the number does not increase.

readerControl.docViewer.getAnnotationManager().getAnnotationsList().length

The text you add to the annotation's note is the annotations Contents entry.

To further clarify, non-textual annotations, like Rectangle and Oval, start with an empty Contents entry, and no popup note. While Free Text and Sticky Note annotations have their Contents entry set to the text that you see.
Reply all
Reply to author
Forward
0 new messages