I am using the Webviewer and getting xfdf data from the database. I have extra data in the database to determine annotation comment state and permissions ect. I am then looping through each database xfdf entry and showing on the PDF with the following:
Just correct me if I am wrong but you would like to change the note in the notes panel to reflect a color based on the annotation state. If so, you can loop through the annotations and set the corresponding note to a particular color with this code:
Thanks Andy, i am still going through all the info you sent. BTW - i am trying to add it my code and i am actually calling the state from a database as wanted control outside the pdf. Here is a snippet.
The importAnnotationCommand API call is asynchronous so you will have to await it. I would recommend using the annotationChanged event on the annotation manager to wait for the annotations to be imported: PDFTron WebViewer Class: AnnotationManager. Then I would update the notes in the UI with the colors you want.
You could also opt to set a custom property on the annotations and use the dangerous API I mentioned to make the notes handle the colors.
I ended up with the suggestion of an event listerer on ‘annotationchanged’ and then AnnotationManager.getAnnotationsList().forEach with the iframeWindow.document and specifying the id using its state of completed ect. i am filtering the comments then assign colors as follows: iframeWindow.document.getElementById(‘note_’+annotik.fM).style.backgroundColor = ‘#e8faec’;
its working well and keeps active for new loading and add and modifying of annotaiotn.
However for some reason the colors disappear on deleting an element only? the forEach code is working but not the color change, and only when deleting, so it fixes itself when i add/modify again after deleting.