Thanks! Here’s what I came up with. I probably should have tried this earlier, but for some reason I didn’t think it worked.
const stampTool = viewerInstance.current.Core.documentViewer.getTool(viewerInstance.current.Core.Tools.ToolNames.RUBBER_STAMP);
const defaultStandardStamps = stampTool.getStandardStamps().filter(a => a !== 'Draft');
stampTool.setStandardStamps([
'/some/stamp.png',
// Add the default WebViewer stamps
...defaultStandardStamps,
]);
viewerInstance.current.Core.annotationManager.addEventListener('annotationChanged', async (annots, action, {imported}) => {
if (!imported) {
for (const annot of annots) {
if (annot instanceof viewerInstance.current.Core.Annotations.StampAnnotation && action === 'add') {
if (!defaultStandardStamps.some(name => annot.Icon === name)) {
// Resize the stamp while maintaining its aspect ratio
const aspectRatio = annot.Width / annot.Height;
annot.Width = Math.round(64 * aspectRatio);
annot.Height = 64;
viewerInstance.current.Core.annotationManager.redrawAnnotation(annot);
}
}
}
}
});
Anyway, this solves my main issue, but I still have a couple minor questions.
First, I’m still not sure how I can rename my custom stamps so they don’t have the “Draft” icon property. At the moment I’m just not including the default “Draft” icon, so it doesn’t get caught up in this logic. Because I don’t need to resize it.
And from this thread:
It seems like the resizing of the preview that pops up when you select a stamp isn’t supported, at least as of last year. If that is still the case, that’s fine. I was just curious as to whether it is now supported.