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

Javacript warnings

Community Beginner ,
Sep 04, 2023 Sep 04, 2023

I want to remove this warnigs , i made 2 js file one is customMenu.js second is folderLevelScript.js
code here : 
customMenu.js

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

  app.addMenuItem({
    cName: "Upload",
    cParent: "LegalEdge",
    cExec: "showUploadDialog()",
  });
  app.addMenuItem({
    cName: "config",
    cParent: "LegalEdge",
    cExec: "configdialouge()",
  });
  app.addMenuItem({
    cName: "About",
    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
    );
  }
}

function configdialouge() {
  // 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: "Provide Baseurl of the Web Service Api:",
              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: "Username:", 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: "PassWord:", 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: "Cofirm Password:", 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 = "https://localhost:3000";
  oDlg.usnm.vers = "Alfred";
  oDlg.usnm.lfnu = "********";
  oDlg.usnm.lccn = "********";

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

folderLevelScript.js
function
myTrustedFunction() {
  createTopMenu();
}

// Call the trusted function when Acrobat starts
myTrustedFunction();

and then paste the code in this location
Arjun31926974q4ne_0-1693824688182.png



Still facing this issue . How can i resolve this 




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 , Modern Acrobat , PDF , PDF forms , Print and prepress , Rich media and 3D , Scan documents and OCR , Security digital signatures and esignatures , Standards and accessibility
528
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 ,
Sep 04, 2023 Sep 04, 2023

You must create a trusted function. The name myTrustedFunction is not enough.

https://www.pdfscripting.com/public/Trust-and-Privilege-in-Acrobat-Scripts.cfm 

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 ,
Sep 04, 2023 Sep 04, 2023
LATEST

Besides the trust issue pointed out by Bernd, the menus in the new 64bit Acrobat have changed. This code, once its working, will only work in the old Acrbat DC UI. 

 

 

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