Skip to main content
October 6, 2016
Question

Ajax call on acrobat form by javascript

  • October 6, 2016
  • 7 replies
  • 3790 views

Is it possible to make an ajax call on acrobat form by javascript so that I can get data from server and fill the dropdown list item on runtime?

This topic has been closed for replies.

7 replies

October 7, 2016

Thanks for response!

What I want to do is use acrobat e-form to replace traditional web form in my web application, so I need to make a interactive e-form to deal with user selection.

For example, one of the use case, I need to make an ajax call on acrobat form by javascript so that I can get data from server and fill the dropdown list item on runtime

Is that acrobat e-from possible to act as traditional web form? Or LiveCycle server is the solution?

Please advice!

Karl Heinz  Kremer
Community Expert
Community Expert
October 7, 2016

You can submit form data via FDF or XFDF (or even HTML) and then respond back to the form with FDF or XFDF (in this case, HTML is not an option, that's why I stick with FDF/XFDF both ways). The only drawback is that you can only send and receive information in form fields, so you may need to create some hidden fields that you use just for this type of communication.

Take a look at this for more information: Acrobat DC SDK Documentation - Doc.submitForm()

Legend
October 7, 2016

There is much to consider that you may not be aware of. Such a form would need the Mac or Windows version of Acrobat Reader. Can you force all your users to have this configuration? Are you sure nobody will ever want to use it from their tablet or phone? Frankly, I can see no reason whatever to move from working HTML forms to PDF forms. Even Adobe are moving away from it.

try67
Community Expert
Community Expert
October 6, 2016

No, you can't use Ajax in a PDF, but you can do an HTTP request or a call to a SOAP service. It's all documented under the Net object in the Acrobat JavaScript API Reference.

October 6, 2016

Thank you so much try67!

I follow the Acrobat JavaScript API Reference to create the following script.js and put it into the folder level folder:

function ajax(cURL) {

    var params =

    {

            cVerb: "GET",

            cURL: cURL,

            oHandler:

            {

                    response: function(msg, uri, e,h){

                            var stream = msg;

                            var string = "";

                            string = SOAP.stringFromStream( stream );

                            app.alert( string );

                    }

            }

    };

    Net.HTTP.request(params);

}

then I create a button on the pdf form and call a javascript: ajax('http://localhost/app/ajaxCall');

But it return this error: NotAllowedError: Security setting prevent access to this property or method.

Any suggestions?

try67
Community Expert
Community Expert
October 6, 2016

Using this method requires "forms rights", which usually means a special right applied with a LiveCycle server application...