Custom button in annotation edit popup

72 views
Skip to first unread message

Nitin Chaudhary

unread,
Nov 6, 2017, 4:55:06 PM11/6/17
to PDFTron WebViewer
Hi,

I am adding custom buttons to the annotation edit popup. I want to use these buttons to dynamically add content to ".staticNoteContents" area of annotation Note. Is there a way of doing that.

Regards,
Nitin

Justin Jung

unread,
Nov 6, 2017, 7:11:47 PM11/6/17
to PDFTron WebViewer
Hello,

There is setNoteContents function from annotation manager. For example,

var originalContents = annotation.getContents();
annotManager.setNoteContents(annotation, originalContents + ' extra text');

Justin Jung
Software Developer
PDFTron Systems Inc.

Nitin Chaudhary

unread,
Nov 7, 2017, 12:43:23 PM11/7/17
to PDFTron WebViewer
Hi Justin,

I am using this code to add a button: 

var customButton = $('<button type="button" class="roundedCornerButton">Test Button</button>');
customButton
.on('click', function() {
 
console.log('Clicked custom button');
 
// Code to change note content.
  // Is there a way of knowing which annotation was clicked
 // so, that I can use code provided by you
});

window.AnnotationEdit.buttons.push({
 
element: customButton,
  isHidden
: function() {
   
return false;
 
}
});

Actually I was hoping if there is a way that I can access the annotation to which annotation edit popup belongs to in the custom button's onClick function.

Regards,
Nitin

Justin Jung

unread,
Nov 7, 2017, 3:17:35 PM11/7/17
to PDFTron WebViewer
You can get the array of selected annotations, and refer to the first one.

var annotation = readerControl.docViewer.getAnnotationManager().getSelectedAnnotations()[0];

Nitin Chaudhary

unread,
Nov 7, 2017, 3:40:35 PM11/7/17
to PDFTron WebViewer
Hi Justin,

Thanks a lot for your help. It worked like a charm.

Regards,
Nitin
Reply all
Reply to author
Forward
0 new messages