Skip to main content
RajSekar
Participant
Jun 17, 2016 7:01 AM UTC
Question

How to delete Stamp using JAVASCRIPT

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 is closed to new replies. Start a new post to keep the conversation going.

4 replies

try67
Community Expert
Community Expert
Jun 16, 2023 9:00 AM UTC

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.

Translate
bebarth
Community Expert
Community Expert
Jun 14, 2023 7:10 PM UTC

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

@+

Translate
Participant
Jun 13, 2023 8:49 PM UTC

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. 

Translate
Legend
Jun 17, 2016 2:07 PM UTC

What an odd forum to ask this question...

Translate