Skip to main content
McNugget84
Participating Frequently
March 17, 2023
Question

How to Prompt User for String input

  • March 17, 2023
  • 2 replies
  • 779 views

Hello,

I have a Script that batch Stamps Multiple Files. 

Would like that at each file the user is propmted to write which Stamp to Use (via a dialog box) 

this.addAnnot({type:"Stamp", page:0, AP:"MyStamp001", rec[x1,y1,x1,y1],})

The idea is that "MyStamp001" is to be inserted by the User ("UserStampString"). If "UserStampString" Exists then Good. Else, if  "UserStampString" deos not exists then Apply default "MyDefaultStamp000" for example. 
Thank you in advance. 
Kind Regards

 

 

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
March 18, 2023

If a stamp with a non-existant AP is applied to a page, Acrobat will create a stamp object with all the regular stamp properties. So it's tricky. But there is a way for the script to know whether or not a particular stamp exists. 

If the stamp is applied to a point rather than a rectangle, then the rectange of the resulting annotation will be the natural size of the stamp for a real stamp AP, but for a non-existant stamp AP, the rectangle will remain a point. So the script can test the stamp rectangle after its applied to decide if the AP needs to be set to default AP. 

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
bebarth
Community Expert
Community Expert
March 18, 2023

I guess it's not possible to get a list of all stamp names available.

Thom Parker
Community Expert
Community Expert
March 20, 2023

Not from a script. 

Many versions ago, all the stamps were on a menu, and it's possible to get a list of menu names. This menu was very deliberately removed for security reasons. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
March 18, 2023

That's not going to work. If they specify a stamp name that doesn't exist it will add a stamp with a black cross in the middle. You have no way of knowing it's a bad name.