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

How to Prompt User for String input

Community Beginner ,
Mar 17, 2023 Mar 17, 2023

Copy link to clipboard

Copied

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

 

 

TOPICS
Acrobat SDK and JavaScript , Windows

Views

366

Translate

Translate

Report

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 ,
Mar 18, 2023 Mar 18, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 ,
Mar 18, 2023 Mar 18, 2023

Copy link to clipboard

Copied

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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 ,
Mar 18, 2023 Mar 18, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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 ,
Mar 20, 2023 Mar 20, 2023

Copy link to clipboard

Copied

LATEST

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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