Skip to main content
RajSekar
Participant
June 17, 2016
Question

How to delete Stamp using JAVASCRIPT

  • June 17, 2016
  • 4 replies
  • 1032 views

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.

This topic has been closed for replies.

4 replies

try67
Community Expert
Community Expert
June 16, 2023

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.

bebarth
Community Expert
Community Expert
June 14, 2023

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();
	}
}

@+

Participant
June 13, 2023

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. 

Legend
June 17, 2016

What an odd forum to ask this question...