Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to delete Stamp using JAVASCRIPT

New Here ,
Jun 17, 2016 Jun 17, 2016

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.

TOPICS
Acrobat SDK and JavaScript
968
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 17, 2016 Jun 17, 2016

What an odd forum to ask this question...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 13, 2023 Jun 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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 14, 2023 Jun 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();
	}
}

@+

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 16, 2023 Jun 16, 2023
LATEST

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines