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

Acrobat triggers user input popup before selecting a stamp

Participant ,
Jan 12, 2016 Jan 12, 2016

Hi,

I'm trying to create a custom stamp for my invoices. I would like to trigger user for inserting date and note.

The problem is that when I want to add the stamp to the document, Acrobat prompts me with the input popup when I rollover "Dynamic" in the Stamps dropdown menu, before I even reach dynamic stamps list. In order to get to the stamp list, I have to click twice OK, and only then I get to the dynamic stamp list. When I select my stamp finally it prompts me again.

What triggers this? Why? I want to be prompted only after I select the stamp from the stamp list.

I have two fields, Date and Note. These are the two scripts I use:

DATE

var cResponse = app.response({

cQuestion: "Insert payment date:",

cTitle: "Date",

cLabel: "Date:"

});

if (cResponse == null) {

event.value = util.printd("dd-mm-yyyy",new Date);

}

else

event.value = cResponse;

NOTE

var cResponse = app.response({

cQuestion: "Insert comment note:",

cTitle: "Note",

cLabel: "Note:"

});

if (cResponse == null) {

event.value = "";

}

else

event.value = cResponse;

This is when the popup is triggered:

Screen Shot 2016-01-12 at 14.09.05.png

This is how the custom stamp looks like, with two fields:

Screen Shot 2016-01-12 at 14.11.25.png

Thank you.

TOPICS
Acrobat SDK and JavaScript
3.8K
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

correct answers 1 Correct answer

Community Expert , Jan 12, 2016 Jan 12, 2016

Dynamic stamps in Acrobat are not trivial - as you found out. Take a look at this tutorial: https://acrobatusers.com/tutorials/dynamic_stamp_secrets

The element that is missing from your stamp script is the check for event.source.forReal and for the stamp name. Because of that, your stamp dialog gets triggered even when the user is not placing this particular stamp.

Translate
Community Expert ,
Jan 12, 2016 Jan 12, 2016

Dynamic stamps in Acrobat are not trivial - as you found out. Take a look at this tutorial: https://acrobatusers.com/tutorials/dynamic_stamp_secrets

The element that is missing from your stamp script is the check for event.source.forReal and for the stamp name. Because of that, your stamp dialog gets triggered even when the user is not placing this particular stamp.

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
Participant ,
Jan 12, 2016 Jan 12, 2016

OK, but where do I get the stamp name? Is it a file name?

The link that you posted suggests to use JS console with this code in order to retrieve the stamp name:

this.selectedAnnots[0].AP

I have opened the stamp PDF file (JLxAP6tn8CjmyXUQlGCSYB.pdf) and executed the code from the js console.

What I get, is an error:

TypeError: this.selectedAnnots is undefined

1:Console:Exec

undefined

What am I doing wrong?

Thank you.

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 ,
Jan 12, 2016 Jan 12, 2016

It's not the file name, and you're using the code incorrectly.

Open any PDF file and apply the stamp to it (disable all the scripts if

necessary so they don't interfere).

Then select that stamp with the mouse, open the JS Console (Ctrl+J) and

then run that code from there.

It will print out the AP value for your stamp which you need to include in

your code.

On Tue, Jan 12, 2016 at 8:57 PM, haligaliharun <forums_noreply@adobe.com>

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 ,
Jan 12, 2016 Jan 12, 2016

You need to follow the instructions step by step. It's all in the tutorial. You will need to place your stamp on a document, and then select that stamp, and then run this one line of JavaScript in the console. Again, every single step in the tutorial is important, and you need to follow 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
Participant ,
Jan 12, 2016 Jan 12, 2016
LATEST

OK got it, yes I didn't follow instructions step by step. I had problem placing stamps because it was triggering many popups, so I skipped that part ...

The final working code looks like this:

if (event.source.forReal && (event.source.stampName == "#77ZFee0H5yOCBu7K4CUjOC")) {

  var cResponse = app.response({

    cQuestion: "Insert payment date:",

    cTitle: "Date",

    cLabel: "Date:"

  });

  if (cResponse == null) {

    event.value = util.printd("dd-mm-yyyy", new Date);

  } else {

    event.value = cResponse;

  }

}

Thanx.

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