WebViewer Version:
Do you have an issue with a specific file(s)?
Can you reproduce using one of our samples or online demos?
Are you using the WebViewer server?
Does the issue only happen on certain browsers?
Is your issue related to a front-end framework?
Is your issue related to annotations?
Please give a brief summary of your issue:
(Think of this as an email subject)
Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)
I’m working on a PDF signing and annotation tool using PDFTron. In my application, I have a set of annotation buttons (like text and signature) that can be dragged and dropped onto the PDF. When dropped, they initially appear as TextAnnotations
. After dropping, I have a “Save” button that finalizes (or “sticks”) these annotations to the PDF. Users can then type into text fields or apply their digital signature in the signature fields.
I’m using PDFTron’s annotation event listeners (e.g., for annotationChanged
) to track actions like adding, modifying, or deleting annotations. However, I’ve noticed that these listeners sometimes work inconsistently. For example, when I drop the annotations, the console logs as expected. But after clicking the “Save” button and finalizing them, sometimes I get the annotation change events (like add
, modify
, or delete
), and sometimes I don’t.
My main goal is to track every interaction with each annotation after the “Save” step—specifically, I want to know when a user signs a signature field or types into a text field. In the future, I want to track which users have signed which fields. For example, if my PDF has two signature fields and only one person signs it, I should be able to detect and log that action in real time.
Could you please guide me on how to reliably listen for such annotation interactions—especially after annotations have been applied—to ensure I can track each activity, including signing and typing?
annotationManager.addEventListener(
"annotationChanged",
(annotations, action) => {
console.log("action",action)
if (action === "delete") {
console.log("Annotation deleted");
annotations.forEach((annot) => {
if (window.fieldMap.has(annot.Id)) {
setFieldCount((prevCount) => Math.max(prevCount - 1, 0));
window.fieldMap.delete(annot.Id);
}
});
} else if (action === "add") {
console.log("Annotation added");
} else if (action === "modify") {
console.log("Annotation mofified");
}
}
);
Please provide a link to a minimal sample where the issue is reproducible: