Skip to main content
Participating Frequently
April 9, 2025
Question

Dynamic Stamp with auto Popup for data entry

  • April 9, 2025
  • 2 replies
  • 2124 views

Dear Adobe Community,

I’m trying to create a custom stamp that, when added to a document, automatically shows a popup dialog. This dialog should first ask the user (a) how many rows need to be filled, and then (b) display input fields for each row where the user can enter data separated by semicolons. These values are then parsed and placed into individual fields.

This works perfectly when I use the JavaScript in a regular PDF form. However, as soon as I turn it into a dynamic stamp, the input dialog no longer appears.

 

var maxRows = 5;

var zeilenStr = app.response({
    cQuestion: "Wie viele Zeilen möchten Sie befüllen? (1–5)",
    cTitle: "Zeilenanzahl eingeben",
    cDefault: "3"
});

var anzahl = parseInt(zeilenStr);
if (isNaN(anzahl) || anzahl < 1 || anzahl > maxRows) {
    app.alert("Ungültige Anzahl. Bitte zwischen 1 und 5 angeben.");
} else {
    for (var i = 1; i <= anzahl; i++) {
        var eingabe = app.response({
            cQuestion: "Werte für Zeile " + i + " eingeben (mit Semikolon getrennt):\nMontant;Compte;Analytique;Type activite",
            cTitle: "Zeile " + i,
            cDefault: ""
        });

        if (eingabe) {
            var werte = eingabe.split(";");

            if (werte.length > 0) this.getField("MontantRow" + i).value = werte[0];
            if (werte.length > 1) this.getField("CompteRow" + i).value = werte[1];
            if (werte.length > 2) this.getField("AnalytiqueRow" + i).value = werte[2];
            if (werte.length > 3) this.getField("Type activiteRow" + i).value = werte[3];
        }
    }
}

 

Thank you very much for your help!
Regards
Kremer

2 replies

PDF Automation Station
Community Expert
April 9, 2025
try67
Community Expert
April 9, 2025

Please search the forum. This issue was discussed here plenty of times in the past, including full tutorials, code examples and even a book written on it!

kremerSKBAuthor
Participating Frequently
April 9, 2025

Hello,
I've already read through several posts and tried many different approaches, but unfortunately, the popup never appears when using the stamp.

Attached is a sample PDF with the stamp. All form fields are properly defined, and there's a hidden field containing the JavaScript code. The stamp name is also set correctly.

Thank you in advance!

kremerSKBAuthor
Participating Frequently
April 16, 2025

Dropdowns are initialized with an Object, as shown by Try67 above:

dialog.load({
"Mon1" : {"100€": 1, "200€": -2, "300€": -3}
});

 

This same object is returned with the "dialog.store()" function.  So to get a selected value the script must loop over all object members and find the one with a positive value. 

 


Hello,
thank you for your information. This now is working fine.
Ass a nice to have, I wanted to create for each line a dropdown in the secon column that loads different content reagrding of the selected value in the first dropdown.

Is this even possible in Acrobat Stamps?

 

Thank you in advance