Acrobat Javascript in Chrome: how to trigger a HTTP request? [closed]

Tags: , , ,



I’m working on an intelligent PDF file. It’s supposed to send some simple data to a certain URL:

this.getURL('https://something.com/data1/data2/data3');

However this doesn’t work if the PDF was opened in a browser, only in Acrobat Reader. Apparently browsers only support a very limited subset of JavaScript within the already very limited Acrobat JavaScript.

Is there a way to get around this?

I can add a button to the form and ask the user to click it. It’s lame, but better than nothing. But then I can only open a hardcoded URL and can’t send any dynamic data with it.

I wonder if it’s possible to programmatically trigger a button?

If neither works, is it possible to try to “talk” to Chrome from inside the PDF reader?

(Bonus question to whoever flagged this question: what part isn’t clear for you?)

Answer

OK, here are the answers.

You can’t trigger a HTTP request from Javascript unless the PDF is opened in Adobe Acrobat Reader, and period.

It is possible to add a PDF form with a Submit button to the document with a HTTP POST request as action, but that will also only work in Acrobat Reader. Chrome and Edge will send the POST, but with an empty request body, and Firefox won’t do anything.

No, it’s not possible to programmatically click a button.

No, it’s not possible to call a JavaScript function on the browser from the PDF document.

All in all, just forget using Acrobat Javascript for anything, as it will never be even remotely reliable.



Source: stackoverflow