Skip to main content
McNugget84
Participating Frequently
Mar 17, 2023 11:48 AM UTC
Question

How to Prompt User for String input

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

4 replies

Thom Parker
Community Expert
Community Expert
Mar 18, 2023 5:43 PM UTC

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. 

 

 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
bebarth
Community Expert
Community Expert
Mar 18, 2023 9:57 PM UTC

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

Translate
Thom Parker
Community Expert
Community Expert
Mar 20, 2023 6:10 PM UTC

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. 

 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
Mar 18, 2023 1:26 PM UTC

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.

Translate