Changing the text of the subject field for the annotations

46 views
Skip to first unread message

Quan Chu

unread,
May 4, 2018, 12:59:08 PM5/4/18
to PDFTron WebViewer
By default, the subject field will be the type of the annotation, such as "Line" or "Highlight" etc
How can I modify this property? I've tried to changed the annotation object directly from the array of annotations but on the right hand Note Panel, the subject of the annotations listed in there won't be affected.

So I'm looking for a way to either
1. updating the format of the subject field whenever an annotation is created
or
2. updating the DOM elements to reflect the changes I made on the annotation object on annotationChanged event



annotationManager.on('annotationChanged', function (e, annotations, action) {
if (!e.imported) {
var privateCheck = sessionStorage.getItem('private');
if (privateCheck !== 'true' && action === 'add') {
for (var i = 0; i < annotations.length; i++) {
annotations[i].Subject = "Private-" + annotations[i].Subject;
}
}

var xfdfString = annotationManager.getAnnotCommand();
var postAnnotationRequest = {
type: 'postAnnotationRequest',
docID: docid,
xfdfData: xfdfString,
docSource: docsource
};
sendMessage(postAnnotationRequest);
}
});

Matt Parizeau

unread,
May 4, 2018, 4:01:41 PM5/4/18
to PDFTron WebViewer
You can get access to the note element from the noteManager:
var noteContainer = noteManager._getNote(annot).getContainer();

And then you can find the subject element and replace the text:
noteContainer.find('.noteSubject').text(annot.Subject);

Similarly you can get the container element in the noteCreated event if you want to edit the Subject at the time the note is created https://www.pdftron.com/documentation/web/guides/basics/components/notes-panel#updating-annotation-notes

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Quan Chu

unread,
May 4, 2018, 6:20:21 PM5/4/18
to PDFTron WebViewer
Thank you so much, that works perfectly. I was playing around with noteManger too but there was no API documentation on it.
Reply all
Reply to author
Forward
0 new messages