Which product are you using?
PDF.js Express Viewer
PDF.js Express Version
8.7.4
Detailed description of issue
Having problems trying to set the default size of the Check Stamp to be smaller on selection.
Expected behaviour
Code snippet
This is the only way I’ve gotten it to work, but this only changes it after it is selected + added to the document. Wanting to change it before selection so it is already the correct size before adding it to the document.
annotationManager.addEventListener('annotationChanged', (annotations, action) => {
if (action === 'add') {
annotations.forEach(annotation => {
if (annotation instanceof Annotations.StampAnnotation) {
// Set the height and width for the RubberStampAnnotation
annotation.setHeight(10); // Set your desired height
annotation.setWidth(10); // Set your desired width (optional)
// Adjust the rectangle
annotation.adjustRect();
// Ensure the annotation gets redrawn with the new size
annotationManager.redrawAnnotation(annotation);
}
});
}
});