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

PDF submit action calling a ajax to post data

New Here ,
Mar 02, 2020 Mar 02, 2020

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript

Views

1.0K

Translate

Translate

Report

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 ,
Mar 02, 2020 Mar 02, 2020

Copy link to clipboard

Copied

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_Acro...

 

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_Acro...

 

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
New Here ,
Mar 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

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 ,
Mar 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

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).

Votes

Translate

Translate

Report

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
New Here ,
Mar 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

Thank you try67. But sorry, I am not able to understand what you are trying to convey. I am pretty naive about this and finding it very difficult. I would be glad if you could elaborate.

Votes

Translate

Translate

Report

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 ,
Mar 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

It means that if you want to use this function you have to install a script on the local machine of each user who will open the file.

Votes

Translate

Translate

Report

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
New Here ,
Mar 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

Oh. Got that! Thank you! 🙂

Votes

Translate

Translate

Report

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 ,
Mar 03, 2020 Mar 03, 2020

Copy link to clipboard

Copied

LATEST

You can read about trust in Acrobat scripts here:

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

 

you can test your code from the console window, but this function will not run in the console window when a document is open. 

 

There is a tutorial on the console window here:

https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro

 

 

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

Votes

Translate

Translate

Report

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