How to delete Stamp using JAVASCRIPT
Copy link to clipboard
Copied
We have created New Dynamic stamp to ask for Customer Number through Pop up.
My requirement is when users clicks cancel Button from the POP up, stamp should not gets pasted to PDF.
Is there any way to delete the stamp when we click the cancel Button in the POP Up message.
Copy link to clipboard
Copied
What an odd forum to ask this question...
Copy link to clipboard
Copied
I know this thread is very old, but in case anyone else needs to know, you can use the destroy method.
var annot = this.addAnnot({
page: 0,
type: "Stamp",
name: "StampName",
AP: "#Dapproved",
rect: [32,32,32,32]
});
annot.destroy();
You either pass the annotation to a variable or array to single it out, then add ".destroy();" to delete it.
Copy link to clipboard
Copied
Hi,
In your case, if you only need to delete your stamp "myStamp", you have to use this script:
var annots=this.getAnnots();
if (annots!=null) {
for (var i=0; i<annots.length; i++) {
if (annots[i].type=="Stamp" && annots[i].AP=="myStamp") annots[i].destroy();
}
}
@+
Copy link to clipboard
Copied
The answer is No. Because at the moment the script executes the stamp hasn't been added to the page yet, so it can't locate and remove it. You can only do that after all code has executed, and the comment created.
Maybe it would be possible using the setTimeOut command, to run the script to remove the stamp with a delay, but I'm not 100% sure that will work, either.

