const tool = documentViewer.getTool('AnnotationCreateRubberStamp');
tool.setCustomDrawFunction((ctx, annotation) => {
const { Icon } = annotation;
// `Icon` contains the text content of the stamp
// This example conditionally renders custom content on the stamp only
// if the contents of the stamp are in the approved list of stamps to
// draw on
const stampsToDrawOn = [
'Approved',
'Completed',
'Final',
];
if (stampsToDrawOn.includes(Icon)) {
// Arbitrary example where an image is available in the DOM
const img = document.getElementById('my-company-logo');
ctx.font = '100px serif';
ctx.fillText('Hello world', 0, 0);
ctx.drawImage(
img, // The image to render
0, // The X coordinate of where to place the image
0, // The Y coordinate of where the place the image
25, // The width of the image in pixels
25, // The height of the image in pixels
);
}
});
Is it possible to create a RubberStamp annotation from a button, so click button, or drag from toolbar, I can see we can drag from the dropdown menu, I would like to do this from buttons I have created.
Our “drag and drop” is actually just a preview of the Rubber Stamp before it is placed, you can use showPreview() to view the annotation before it is placed.
Found here: PDFTron WebViewer Class: RubberStampCreateTool
Will this work for you?
Best Regards,
Tyler Gordon
Web Development Support Engineer
PDFTron Systems, Inc. www.pdftron.com