Skip to main content
July 1, 2016
Answered

Question 1: How to add or use jQuery in Folder Level Adobe Javascript. Question 2: How to write normal Javascript in Folder Level Adobe Javascript ie., getElementbyid etc... Please find the code below which shows what I am referring to

  • July 1, 2016
  • 2 replies
  • 1609 views

Below is my Folder Level Javascript which comes as a Pop up when I click on a Custom created button in a PDF reader..

I created a Test.js file and then pasted the below code in it. Then I copy pasted that file in the following path:  C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\JavaScripts

Now I want to know how to add either jQuery Code or the Normal Javascript in the below code. Please give an example.

Note: I am not using the Javascript Forms here. This is a folder ACROJS Javascript.

// Start of Code

app.addMenuItem({ cName: "PERSONAL INFO", cParent: "File", cExec: "helloWorld()" });

var helloWorld = app.trustedFunction(function () {

    app.beginPriv();

var dialog1 = {

description:

{

elements:

[

{

type: "cluster",

name: "Details",

align_children: "align_left",

elements:

[

{

type: "static_text",

name: "First Name"

},

{

type: "edit_text",

alignment: "align_fill",

width: 300,

height: 20

}

]

},

{

alignment: "align_left",

type: "ok_cancel",

ok_name: "Ok",

cancel_name: "Cancel"

}

]

}

};

app.execDialog(dialog1);

app.endPriv();

});

//End of Code

This topic has been closed for replies.
Correct answer Karl Heinz Kremer

Let's take a step back and figure out what "normal" JavaScript is. Normal for you probably means browser based, but that is only your point of reference. Any JavaScript implementation consists of at least the JavaScript core language, and that is what you have in both Acrobat's JavaScript, but also in the browser based JavaScript. Things like the JavaScript syntax are handled in that part of the language, how different types are handled (numbers, strings, arrays, classes, ...), but also a number of library items like e.g. the Date object. In addition to that core language, almost all JavaScript implementations have a second part, which is application specific. In the browser, you are dealing with HTML and windows, and other things that only make sense in the browser environment. In Acrobat, you deal with PDF documents, annotations, form fields,  and more. The web browser specific Javascript is not more or less "normal" than the implementation in Acrobat. You have to get used to a different environment, and that is what the Acrobat JavaScript API reference is for. You will find all Acrobat specific objects and methods described in there. What makes things a bit harder for you is that you probably don't know where the dividing line is between the core language and browser specific extensions, so you will have some re-learning of the language ahead of you.

2 replies

Karl Heinz  Kremer
Community Expert
Karl Heinz KremerCommunity ExpertCorrect answer
Community Expert
July 1, 2016

Let's take a step back and figure out what "normal" JavaScript is. Normal for you probably means browser based, but that is only your point of reference. Any JavaScript implementation consists of at least the JavaScript core language, and that is what you have in both Acrobat's JavaScript, but also in the browser based JavaScript. Things like the JavaScript syntax are handled in that part of the language, how different types are handled (numbers, strings, arrays, classes, ...), but also a number of library items like e.g. the Date object. In addition to that core language, almost all JavaScript implementations have a second part, which is application specific. In the browser, you are dealing with HTML and windows, and other things that only make sense in the browser environment. In Acrobat, you deal with PDF documents, annotations, form fields,  and more. The web browser specific Javascript is not more or less "normal" than the implementation in Acrobat. You have to get used to a different environment, and that is what the Acrobat JavaScript API reference is for. You will find all Acrobat specific objects and methods described in there. What makes things a bit harder for you is that you probably don't know where the dividing line is between the core language and browser specific extensions, so you will have some re-learning of the language ahead of you.

Inspiring
July 1, 2016
try67
Community Expert
Community Expert
July 1, 2016

You can't use jQuery in Acrobat. Well, you can install it as a folder-level script, but it doesn't make any sense. The functions in it have no relevance in this environment. They were developed for web-based JS. Same goes for getElementbyid.

If you describe what you want to achieve we might be able to help you using the tools which ​are​ available and relevant.

July 1, 2016

Hi,

Thanks for the reply -> that was a helpful answer.

I have designed the below and I don't want the empty space to appear.

The empty space should be replaced by the Hiring Info.

Requirement:

In the screen 1 on Left the Empty space should not appear at all.

In the Screen 2 on the right the Empty space on the Top should not appear. It should be replaced by the Hiring Information Cluster Block.

I need a Grid layout in which I can place my Fields.

Please find below my complete code.

////My code

// This should be pasted in the folder : C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\JavaScripts

app.addMenuItem({ cName: "Hiring Info", cParent: "File", cExec: "helloWorld()" });

var helloWorld = app.trustedFunction(function () {

    app.beginPriv();

   

    var dialog2 =

    {

        initialize: function (dialog) {

            dialog.visible({ "CLU2": false });

      

        },

        rd01: function (dialog) {

            // First Option - Enable

            dialog.visible({ "CLU2": false });

            dialog.visible({ "CLU1": true });

        },

        rd02: function (dialog) {

            dialog.visible({ "CLU1": false });   

            dialog.visible({ "CLU2": true });

        },

        // The Dialog Description

        description:

        {

            name: "Data",

            elements:

            [

            {

                type: "view",

                align_children: "align_center",

                elements:

                [

                 {

  type: "static_text",

  name: "Step 1",

  bold: true,

  font: "dialog",

  char_width: 30,

  height: 20,

  alignment: "align_left"

  },

                

                {

                    type: "cluster",

                    align_children: "align_row",

                    elements:

                    [

                    {

                        type: "view",

                        align_children: "align_center",

                        elements:

                        [

                        {

                            type: "radio",

                            item_id: "rd01",

                            group_id: "rado",

                            name: "Personal Info"

                        }

                        ]

                    },

                    {

                        type: "view",

                        align_children: "align_center",

                        elements:

                        [

                        {

                            type: "radio",

                            item_id: "rd02",

                            group_id: "rado",

                            name: "Hiring Info"

                        }

                        ]

                    }

                    ]

                },

                // Add the Individual Types....

                //First

                {

                    type: "cluster",

                    item_id: "CLU1",

                    align_children: "align_left",

                    elements:

                    [

                 {

  type: "button",

  name: "Personal Data",

  item_id: "BUT1",

  bold: true,

  font: "dialog",

  width: "40",

  height: 20,

  alignment: "align_left"

  },

                    {

                        type: "view",

                        align_children: "align_row",

                        elements:

                        [

                        {

                            type: "static_text",

                            item_id: "1000",

                            name: "First Name",

                            width: 100

                        },

                        {

                            item_id: "1001",

                            type: "edit_text",

                            width: 100,

                            height: 20

                        }

                        ]

                    },

                    {

                        type: "view",

                        align_children: "align_row",

                        elements:

                        [

                        {

                            type: "static_text",

                            name: "Last Name",

                            item_id: "1002",

                            width: 100

                        },

                        {

                            type: "edit_text",

                            width: 100,

                            item_id: "1003",

                            height: 20

                        }

                        ]

                    },

                    {

                        type: "view",

                        align_children: "align_row",

                        elements:

                        [

                        {

                            type: "static_text",

                            item_id: "1004",

                            name: "Birth Date",

                            width: 100

                        },

                        {

                            type: "edit_text",

                            width: 100,

                            item_id: "1005",

                            height: 20

                        }

                        ]

                    }

                   

                    ]

                },

                {

                    type: "cluster",

                    item_id: "CLU2",

                    align_children: "align_left",

                    elements:

                    [

                {

  type: "button",

  name: "Hiring Information",

  bold: true,

  item_id: "BUT2",

  font: "dialog",

  width: "40",

  height: 20,

  alignment: "align_left"

  },

                    {

                        type: "view",

                        align_children: "align_row",

                        elements:

                        [

                        {

                            type: "static_text",

                            name: "Process Name",

                            item_id: "1008",

                            width: 100

                        },

                        {

                            type: "edit_text",

                            item_id: "1009",

                            width: 100,

                            height: 20

                        }

                        ]

                    },

                    {

                        type: "view",

                        align_children: "align_row",

                        elements:

                        [

                        {

                            type: "static_text",

                            name: "Assigned Manager",

                            item_id: "1010",

                            width: 100

                        },

                        {

                            type: "edit_text",

                            item_id: "1011",

                            width: 100,

                            height: 20

                        }

                        ]

                    },

                    {

                        type: "view",

                        align_children: "align_row",

                        elements:

                        [

                        {

                            type: "static_text",

                            item_id: "1012",

                            name: "Hiring Date",

                            width: 100

                        },

                        {

                            type: "edit_text",

                            item_id: "1013",

                            width: 100,

                            height: 20

                        }

                        ]

                    }

                    ]

                },

                {

                    type: "ok_cancel_other",

                    ok_name: "Ok",

                    cancel_name: "Cancel",

  other_name: "Reset"

                }

                ]

            },

            {

                type: "gap", //add a small vertical gap between

                height: 20 //..radio fields and buttons

            },

            ]

        }

        // End of Code for linking the Document for the Client....

    };

    app.execDialog(dialog2);

    app.endPriv();

});