Skip to main content
Participant
August 28, 2023
Answered

How can i get the values of all input after click on save button in adobe acrobate ?

  • August 28, 2023
  • 2 replies
  • 750 views

I am making javacsript plugin , here's the code , i am trying to get the input value , so i canhit a post api and send input's data into that , i tried all getfields methods and all , nothing working at all , 

function createTopMenu() {
  app.addSubMenu({
    cName: "LegalEdge",
    cParent: "File",
  });

  app.addMenuItem({
    cName: "Upload",
    cParent: "LegalEdge",
    cExec: "showUploadDialog()",
  });
}

function showUploadDialog() {
  var dialog = {
    description: {
      name: "Upload to LegalEdge",
      elements: [
        {
          type: "view",
          elements: [
            {
              type: "static_text",
              name: "File Name:",
            },
            {
              type: "edit_text",
              item_id: "fileName",
              char_width: 30,
            },
          ],
        },
        {
          type: "view",
          elements: [
            {
              type: "static_text",
              name: "Version:",
            },
            {
              type: "edit_text",
              item_id: "version",
              char_width: 30,
            },
          ],
        },
        {
          type: "view",
          elements: [
            {
              type: "static_text",
              name: "LegalEdge File Number:",
            },
            {
              type: "edit_text",
              item_id: "fileNumber",
              char_width: 30,
            },
          ],
        },
        {
          type: "view",
          elements: [
            {
              type: "static_text",
              name: "LegalEdge Court Case Number:",
            },
            {
              type: "edit_text",
              item_id: "courtCaseNumber",
              char_width: 30,
            },
          ],
        },
        {
          type: "ok_cancel",
          ok_name: "Save",
          cancel_name: "Close",
        },
      ],
    },
    commit: function (dialog) {
   

      var uploadedData = {
        fileName: dialog.store()["fileName"].value,
        version: dialog.store()["version"].value,
        fileNumber: dialog.store()["fileNumber"].value,
        courtCaseNumber: dialog.store()["courtCaseNumber"].value,
      };
      saveUploadedData(uploadedData);
    },
  };
 
  app.execDialog(dialog);
}

function saveUploadedData(data) {
  var message =
    "File Name: " +
    data.fileName +
    "\nVersion: " +
    data.version +
    "\nFile Number: " +
    data.fileNumber +
    "\nCourt Case Number: " +
    data.courtCaseNumber;
  app.alert(message);
}

createTopMenu();

can anyone look into and help me ? 
This topic has been closed for replies.
Correct answer try67

The item_id values in the Dialog object must be 4 characters long. No more, no less.

2 replies

Thom Parker
Community Expert
Community Expert
August 28, 2023

Is this code in a JavaScript file?  Adding a menu item can only be done in a folder level script at app initialization (or from the console).  In either case the "createTopMenu" function is unnecessary.  You'll also have problems with this code in the new 64bit UI, since  the parent "File" menu has been moved to the new "Hamburger" menu, and new restrictions have been placed on creating menu items. 

 

You'll find some information on creating popup custom dialogs and a dialog designer here:

https://www.pdfscripting.com/public/ACRODIALOGS-OVERVIEW.cfm

  

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 28, 2023

The item_id values in the Dialog object must be 4 characters long. No more, no less.