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.
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:
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
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.
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).
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.
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.
Copy link to clipboard
Copied
Oh. Got that! Thank you! 🙂
Copy link to clipboard
Copied
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