Detailed description of issue
Is there anyway to automatically or programmatically apply a timestamp at the time someone clicks sign on a PDF document?
Expected behaviour
Does your issue happen with every document, or just one?
No I don’t, I was look for a simple example of how it could be done. We’re pretty flexible but the requirement is that on sign of a signature field in a PDF that a label or something gets dropped off with the date time that isn’t editable by the user. Anything of that nature would work. If need be it could just be below signature or at the bottom of the page.
Here is an example that adds a free text annotation underneath a signature. It locks the free text so it cannot be modified. Feel free to make any changes.
annotationManager.addEventListener('annotationChanged', annotations => {
if (annotations[0].Subject === 'Signature' && !annotations[0].isGrouped()) {
const annotation = annotations[0];
const textAnnot = new Annotations.FreeTextAnnotation(); // create free text annotation
textAnnot.PageNumber = annotation.PageNumber; // set page number equal to stamp's page number
textAnnot.X = annotation.X; // set x position equal to stamp's x position
textAnnot.Y = annotation.Y + annotation.Height; // set y position to be below the stamp
// set height, width and author of the free text annotation
textAnnot.Width = annotation.Width;
textAnnot.Height = 20;
textAnnot.Author = annotation.Author;
textAnnot.setContents(`Date: ${new Date().toLocaleString()}`); // set date
textAnnot.Locked = true; // make it read-only
annotationManager.addAnnotation(textAnnot);
annotationManager.redrawAnnotation(textAnnot);
annotationManager.groupAnnotations(textAnnot, [annotation]); // group annotations so they can be moved together
}
});