0

I need to run javascript code from a PDF to post data to an HCL Leap application. Is there anyway in which I can use xmlhttprequest within adobe, or does anyone have a suggestions on modifying to ajax or similar?

Tried having the javascript install npm install xmlhttprequest

var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhr = new XMLHttpRequest();
var jp = {};
jp.flowState = 'ST_PendingPDFupload';
jp.pressedButton = 'S_Submit1';
jp.F_Value1 = this.getField("F_Value1").value.toString();
var s = JSON.stringify(jp); //covert to string to send in XHR
var UID = this.getField("UID").value.toString();
var urla = 'https://domain/forms-basic/secure/org/data/ba48a093-5a1d-40ef- 
87f6-bb196b95fa9f/F_NewForm1/'
var urlb = '?freedomIdentifyKey=XX'
var url = (urla + UID + urlb)
var client = new XMLHttpRequest(); //open an HTTP request
client.open("PUT",url,false);
client.setRequestHeader('Content-Type', 'application/json');
client.setRequestHeader('Accept', 'application/json');
client.setRequestHeader('Cookie', 'freedomIdentifyKey=XX');
client.send(s);

ReferenceError: require is not defined

  • 1
    Possible duplicate of [Client on node: Uncaught ReferenceError: require is not defined](https://stackoverflow.com/questions/19059580/client-on-node-uncaught-referenceerror-require-is-not-defined) – r g May 21 '19 at 17:25

1 Answers1

0

You reference Adobe in your question but not Acrobat specifically. If your PDF is being viewed in Adobe Acrobat or Reader you can use Acrobat JavaScript... which is quite different from Browser JavaScript; it uses the same JavaScript Core but has a different object model.

Look at the Net.HTTP.request method at the URL below. The Net.HTTP object allows access to web services that use HTTP. However, you will need to install a folder level JavaScript into each copy of Acrobat that needs to use this method for security reasons.

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/index.html#t=Acro12_MasterBook%2FJS_API_AcroJS%2FNet_HTTP_methods.htm%23TOC_requestbc-1&rhtocid=_6_1_8_50_0_0

joelgeraci
  • 4,606
  • 1
  • 12
  • 19