Skip to main content
Participant
September 25, 2024
Question

Create Dynamic Stamp with Checkbox

  • September 25, 2024
  • 1 reply
  • 738 views

I am completely new to dynamic stamps and have zero knowledge of javascript, but have managed to cobble together various javascript from google to create a Stamp with the date automatically populating : 

event.value = (new Date()).toString(); AFDate_FormatEx("h:MM tt dd/mm/yyyy");

 

And 2 empty fields that the user can input text (name and code): 

if (event.source.forReal && (event.source.stampName == "#hA4B5jvsuNXthXqaB8murC")) {
if ("ok" == app.execDialog(dialog1)) {
this.getField("Field1").value = dialog1.field1;
this.getField("Field2").value = dialog1.field2;
}
}

 

I would like to add 2 checkboxes to the stamp (Invoice and Credit Card) but I have no idea what javascript I need, or where to put the javascript to get the boxes to work.

 

Any help or advice would be very much appreciated.

 

Thanks

This topic has been closed for replies.

1 reply

PDF Automation Station
Community Expert
Community Expert
September 25, 2024

You can't just call app.execDialog(dialog1) without first defining dialog1.  You must build a dialog window iwith 2 text fields and two check boxes or radio buttons using JavaScript and assign the variable dialog1 to the dialog before executing it.  Popup dialogs are complicated to code.  You can start here:

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#dialog

Make the export values of the check boxes in your stamp true because the dialog check boxes or radio buttons return either true or false, depending on whether they are checked.