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

Input boxes popup before can select stamp - Custom Javascript stamp Acrobat 9

New Here ,
Oct 19, 2017 Oct 19, 2017

Copy link to clipboard

Copied

I made a custom stamp that I have been using for a while, it has 7 inputs to type in and with pop up boxes.  My issue is that I have never had it working properly and every time I go near the stamp button the popups for data entry appear before I can choose the stamp.  It gets really frustrating.

I have looked for many hours online but I can't exactly work out which part of the code I'm getting wrong.  I worked out that I needed to get the stamp name from the code (which I've done) but I don't know how to meld the event.source.forReal code with my code!  I also had the javascript calculations seperate for all the boxes with inputs but I've seen that its supposed to work much better if you only have one script.

My attempt at adding the code together is at the bottom.  If anybody can help me out and let me know where I've gone wrong I would greatly appreciate it.

Regards Jeremy

code.PNGstamp example.PNG

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

event.value = app.response

var cResponse = app.response({

cQuestion: "Enter Certification Number",

cTitle: "Certification Number",

cLabel: "Certification Number:"

});

if (cResponse == null) {

event.value = "*NVALID*";

}

else

event.value = cResponse;

var cResponse = app.response({

cQuestion: "Enter Certification Date",

cTitle: "Certification Date",

cLabel: "Certification Date:"

});

if (cResponse == null) {

event.value = "*NVALID*";

}

var cResponse = app.response({

cQuestion: "Enter Rating",

cTitle: "Rating",

cLabel: "Rating:"

});

if (cResponse == null) {

event.value = "*NVALID*";

}

else

event.value = cResponse;

var cResponse = app.response({

cQuestion: "Enter Heating Energy",

cTitle: "Heating Energy",

cLabel: "Heating Energy:"

});

if (cResponse == null) {

event.value = "*NVALID*";

}

else

event.value = cResponse;

var cResponse = app.response({

cQuestion: "Enter Cooling Energy",

cTitle: "Cooling Energy",

cLabel: "Cooling Energy:"

});

if (cResponse == null) {

event.value = "*NVALID*";

}

else

event.value = cResponse;

var cResponse = app.response({

cQuestion: "Enter Total Energy",

cTitle: "Total Energy",

cLabel: "Total Energy:"

});

if (cResponse == null) {

event.value = "*NVALID*";

}

else

event.value = cResponse;

var cResponse = app.response({

cQuestion: "Was it rated with downlights?",

cTitle: "Rated with Downlights?",

cLabel: "Rated with Downlights?:"

});

if (cResponse == null) {

event.value = "*NVALID*";

}

else

event.value = cResponse;

}

TOPICS
Acrobat SDK and JavaScript , Windows

Views

2.8K

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

correct answers 1 Correct answer

Community Expert , Oct 21, 2017 Oct 21, 2017

Hello Jeremy,

      To start, just as a helpful communication tip. It is a good idea to try and post code with proper formatting so we can follow it. This is especially important for large scripts.

First thing to do, remove the "event.value = app.response" line.

Just looking at the code there is one glaring issue. "event.value" refers to the value of the form field in which this calculation script is placed. Yet it's used for all the response boxes. For setting the other field values you need to u

...

Votes

Translate

Translate
Community Expert ,
Oct 19, 2017 Oct 19, 2017

Copy link to clipboard

Copied

Look at the debugger for errors.

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
New Here ,
Oct 19, 2017 Oct 19, 2017

Copy link to clipboard

Copied

I don't know how to use it and it crashes the program.  Wouldn't the debugger just show any punctuation mistakes in the code, but show nothing if I've just written the wrong code to work?

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 ,
Oct 19, 2017 Oct 19, 2017

Copy link to clipboard

Copied

The first event.value = app.response is wrong

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
New Here ,
Oct 19, 2017 Oct 19, 2017

Copy link to clipboard

Copied

I tried putting the following brackets, but didn't help

event.value = app.response ();

}

Can you please elaborate on what I have done wrong with this line?  If I can get it to pop up right when I press stamp and get the first couple of things to work correctly I assume I can join all the others on using the same type of code seeing as they worked separately before just not with the stamp identity stuff.

Am I correct that the stamp needs two calculation fields for the stamp identifiers to work properly with pop ups?  This part below and the part at the top of my code mentioning event.source.forReal?

event.value = event.source.source.documentFileName;

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 ,
Oct 19, 2017 Oct 19, 2017

Copy link to clipboard

Copied

Why did you add this line?

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
New Here ,
Oct 20, 2017 Oct 20, 2017

Copy link to clipboard

Copied

Because I don't really know how the coding works, I tried to piece it together from guides I have found.

You seem to give very cryptic answers to show that you know whats wrong or to make me think you do, but without actually helping.  If you don't want to help that's fine but your not helping me at all like this so why are you posting?

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 ,
Oct 21, 2017 Oct 21, 2017

Copy link to clipboard

Copied

Good luck.

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
LEGEND ,
Oct 21, 2017 Oct 21, 2017

Copy link to clipboard

Copied

Take the line out. It's wrong. It doesn't belong. Clear enough?

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
LEGEND ,
Oct 21, 2017 Oct 21, 2017

Copy link to clipboard

Copied

I would look at Dynamic stamp secrets using JavaScript and Acrobat XI by Thom Paker andd down load the examples, make copies of the stamps and experiment.

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
New Here ,
Oct 22, 2017 Oct 22, 2017

Copy link to clipboard

Copied

Thanks for your input although the screenshot of the example at top of page is from that guide

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 ,
Oct 21, 2017 Oct 21, 2017

Copy link to clipboard

Copied

Hello Jeremy,

      To start, just as a helpful communication tip. It is a good idea to try and post code with proper formatting so we can follow it. This is especially important for large scripts.

First thing to do, remove the "event.value = app.response" line.

Just looking at the code there is one glaring issue. "event.value" refers to the value of the form field in which this calculation script is placed. Yet it's used for all the response boxes. For setting the other field values you need to use "this.getField().value"

Typically, if the response box is popping up when you show the stamps menu, then the response box code is unprotected. This is because the stamp script is executed every time the stamp menu item is exposed. However, you're script does protect the calls to app.response. So your description and the code you've posted don't match. There must be other code in the stamp file that is displaying the response box.

There are two ways to approach a fix.

1. Delete all code in the stamp file and start over with one response box in one field calculation script. Once you get that working, then try another, and remember, all calculation scripts must be protected with the first if statement in your code above. i.e. the if that use "event.source.forReal"

2.  This is the really easy solution. Joel Garcia created an incredible tool for automatically creating dynamic stamps, and its free!!! Down load it from here:

http://practicalpdf.com/the-practicalpdf-dynamic-stamp-dialog-creator-for-adobe-acrobat-dc/

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
New Here ,
Oct 22, 2017 Oct 22, 2017

Copy link to clipboard

Copied

Hi Thom,

Thanks for your more in depth response, that makes it a bit more clear.  I'll have a go with these options and let you know how I go.

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 ,
Nov 02, 2017 Nov 02, 2017

Copy link to clipboard

Copied

LATEST

Hi Jeremy,   Glad I could help, and I hope your stamp was a success.

But Now there is yet another option for your dynamic stamp input. It does however require some slightly more advanced programming. At PdfScripting.com you'll find a dialog box editor.  This is a much better UI option than all the response boxes. The editor makes creating the dialog code easy, but you still have to hook it up in your stamp code.

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