Skip to main content
Participant
March 2, 2020
Question

PDF submit action calling a ajax to post data

  • March 2, 2020
  • 1 reply
  • 1798 views

Community,

I am using Adobe Acrobat DC and have created a PDF form and added submit button and action to Run a javascript. I want to post the form fields content via a web.api using ajax post method to my SQL database in C#. Any help here would be highly appreciated.

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
March 2, 2020

AJAX is exactly the same as any regular HTTP Post/Get. Which is exactly what the submit does. So I assume what you really mean is you want the request body to contain JSON. Is this correct?  

If so then the answer is Yes and No.

First the No, the form submit function only formats data in a few different ways. Here's the reference entry:

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_AcroJS%2FDoc_methods.htm%23TOC_submitFormbc-106&rhtocid=_6_1_8_23_1_105

 

There is an HTTP object in the Acrobat JavaScript model that can generate generic HTTP operations, but it requires privilege. 
https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_AcroJS%2FNet_HTTP_methods.htm%23TOC_requestbc-1&rhtocid=_6_1_8_50_0_0

 

I've created a test script for it here (its not free):

https://www.pdfscripting.com/public/HTTP-Access-Tester.cfm

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
March 3, 2020

Thank you very much, Thom, for an instant reply to the post. Although, I forgot to mention at first that I am naive to this and finding it very difficult to make it work. I am attaching a dummy function here. I want to make a POST request with data being sent from Acrobat and received by Web.api method that I have written. I want to also pass the data with the POST method.

 

var aSubmitFields=JSON.stringify({"NameFiling":"vsvs","NamePerson":"sd","TreatyCountry":"fsd","Sec1Name":"sdf"});
var cURL='http://localhost:44242/api/PDFFields';
function ajax(cURL) {
var params =
{
cVerb: "POST",
cURL: cURL,
aHeaders:
{
'Content-Type': "application/json",
}
oHandler:
{
response: function(msg, uri, e,h){
var stream = msg;
var string = "";
string = SOAP.stringFromStream( stream );
app.alert( string );
}
}
};
Net.HTTP.request(params);
}
 
I would be glad if I could get some help here. Thanks in advance!
try67
Community Expert
Community Expert
March 3, 2020

The documentation of the request method clearly states:

Note: This method can only be made outside the context of a document (for example, in a folder level JavaScript).