Copy link to clipboard
Copied
Hello all,
I have been given a task to write a JS script in acrobat pro to POST the complete pdf document currently opened to a server. Also, I need to send some particular cookie along with the request("Cookie" = "...") because of the redirection to the login page of our organization. I know a method of 'doc' object to post the complete pdf document 'submitForm()' but I cannot figure out how can we send that cookie(name, value) thing(if possible using submitForm()). I don't know about any other method. Any help regarding this would be greatly appreciated.
Thanks.
Copy link to clipboard
Copied
It is not possible to set the HTTP Request header values with the "doc.submitForm()" function. The whole point of this function is to submit form data in a secure way. This is not a general purpose HTTP tool. The "secure" part is supposed to mean the user can trust the PDF not to do any not nice things, so this function is boxed into a particular usage model.
Adding cookies to a submit that would allow it to circumvent your organization's security seems like a not so nice thing. What would happen if a malicious user got ahold of this PDF?
The way to get around this issue is to provide an authentication mechanism or limited usage model by submitting to a server script outside the security wall, and have it do whatever transactions need to be done.
Copy link to clipboard
Copied
Is there any way to POST using general javascript functions or using something like fetch API. Also I know of one more function net.http.request(), is it possible using this because it has a parameter aHeaders through which we can send perhaps?
Copy link to clipboard
Copied
Yes, this can be done with net.http.request(), but only from a folder level trusted function. The security notes in the reference entry for this function indicate that it cannot be executed in the context of a document. So I'm not even sure if it would work for privileged document.
If you can install a folder level function on the user's system, then you can use net.http.request(). If not then the proxy server script solution I proposed is your only option.
Copy link to clipboard
Copied
Yes, I am writing a folder level script for the same. So now I had one more question, with the net.http.request(), is it possible to send the complete document(like an attachment)? If yes, how?