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

Post api hit with javascript in adobe acrobate .

Community Beginner ,
Aug 29, 2023 Aug 29, 2023

I want to send the data after click on ok button to this api https://reqres.in/api/users ,and the data is 

   var requestData = {
      flnm: oDlg.usnm.flnm,
      vers: oDlg.usnm.vers,
      lfnu: oDlg.usnm.lfnu,
      lccn: oDlg.usnm.lccn,
    };
here is the code 
function createTopMenu() {
  app.addSubMenu({
    cName: "LegalEdge",
    cParent: "File",
  });

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

function showUploadDialog() {
  // Dialog Definition
  var oDlg = {
    usnm: {
      // Define a nested object for usnm
      flnm: "",
      vers: "",
      lfnu: "",
      lccn: "",
    },

    initialize: function (dialog) {
      dialog.load(this.usnm); // Load the nested object directly
    },
    commit: function (dialog) {
      var data = dialog.store();
      this.usnm.flnm = data.flnm; // Access the nested object's properties
      this.usnm.vers = data.vers;
      this.usnm.lfnu = data.lfnu;
      this.usnm.lccn = data.lccn;
    },
    description: {
      name: "Test Dialog",
      elements: [
        {
          type: "view",
          elements: [
            { name: "Filename:", type: "static_text" },
            { item_id: "flnm", type: "edit_text", char_width: 30 }, // Use "flnm" instead of "usnm.flnm"
          ],
        },
        {
          type: "view",
          elements: [
            // Add a view for the vers field
            { name: "Version:", type: "static_text" },
            { item_id: "vers", type: "edit_text", char_width: 30 }, // Use "vers" instead of "usnm.vers"
          ],
        },
        {
          type: "view",
          elements: [
            // Add a view for the lfnu field
            { name: "LegalEdge File Number:", type: "static_text" },
            { item_id: "lfnu", type: "edit_text", char_width: 30 }, // Use "lfnu" instead of "usnm.lfnu"
          ],
        },
        {
          type: "view",
          elements: [
            // Add a view for the lfnu field
            { name: "LegalEdge Court Case Number:", type: "static_text" },
            { item_id: "lccn", type: "edit_text", char_width: 30 }, // Use "lfnu" instead of "usnm.lfnu"
            { type: "ok_cancel" },
          ],
        },
      ],
    },
  };

  // Dialog Activation
  oDlg.usnm.flnm = "Larry";
  oDlg.usnm.vers = "1.0";
  oDlg.usnm.lfnu = "Sample";
  oDlg.usnm.lccn = "Sample2";

  if ("ok" == app.execDialog(oDlg)) {
    app.alert(
      "flnm: " +
        oDlg.usnm.flnm +
        "\nvers: " +
        oDlg.usnm.vers +
        "\nlfnu: " +
        oDlg.usnm.lfnu +
        "\nlfns: " +
        oDlg.usnm.lccn
    );
  }
}

createTopMenu();
TOPICS
Cancel subscription , Comment review and collaborate Experiment , Crash or freeze , Create PDFs , Edit and convert PDFs , General troubleshooting , How to , Install update and subscribe to Acrobat , JavaScript , PDF , PDF forms , Print and prepress , Rich media and 3D , Scan documents and OCR , Security digital signatures and esignatures , Standards and accessibility
180
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 ,
Aug 29, 2023 Aug 29, 2023
LATEST

If you want to perform an HTTP operation, then you'll need to use the NET.HTTP object. 

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

 

You'll also need to do this from a trusted folder level function. 

Read this as well:

https://www.pdfscripting.com/public/Automating-Acrobat.cfm

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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