Skip to main content
Participating Frequently
October 15, 2021
Answered

Can XMLHttpRequest object be created with JavaScript in PDF document

  • October 15, 2021
  • 3 replies
  • 2988 views

I m planning to add five smilies from sad to happy to the bottom of our invoices to measure user satisfaction. User can choose to submit the chosen one with a button. I want to send this data -which is a number from 1 to 5- to a web server to process.

 

var xhttp = new XMLHttpRequest();
	xhttp.open("POST", "https://mywebservice.asp", true);
	xhttp.setRequestHeader("Content-type", "application/json");
xhttp.send(newdata);

 

Newdata is the number from 1 to 5 mentioned above.

Right now I m opening .pdf files in Firefox browser and getting below error.

 

ReferenceError: XMLHttpRequest is not defined
send@resource://pdf.js/build/pdf.scripting.js line 70 > eval:4:13
@10474819://pdf.js/build/pdf.scripting.js line 70 > eval:9:1
globalEval@resource://pdf.js/build/pdf.scripting.js:70:41
_runActions@resource://pdf.js/build/pdf.scripting.js:3100:14
_dispatchDocEvent@resource://pdf.js/build/pdf.scripting.js:3067:16
dispatch@resource://pdf.js/build/pdf.scripting.js:2613:28
_dispatchEvent@resource://pdf.js/build/pdf.scripting.js:2025:27
__webpack_modules__</initSandbox/<@resource://pdf.js/build/pdf.scripting.js:254:22

This topic has been closed for replies.
Correct answer JR Boulay

- Firefox is not a PDF reader, it's a browser which, like the others, does not respect all the specifications of the PDF format.

 

- Answer is yes and yes.

See these tutos:

https://acrobatusers.com/tutorials/form-submit-e-mail-demystified/

https://acrobatusers.com/tutorials/print/submitting-data/

https://khkonsulting.com/2017/08/connect-database-pdf-form-time-without-soap/

3 replies

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
October 19, 2021

- Firefox is not a PDF reader, it's a browser which, like the others, does not respect all the specifications of the PDF format.

 

- Answer is yes and yes.

See these tutos:

https://acrobatusers.com/tutorials/form-submit-e-mail-demystified/

https://acrobatusers.com/tutorials/print/submitting-data/

https://khkonsulting.com/2017/08/connect-database-pdf-form-time-without-soap/

Acrobate du PDF, InDesigner et Photoshopographe
Armin5E0CAuthor
Participating Frequently
October 19, 2021

This is what I was looking for:

https://acrobatusers.com/tutorials/print/submitting-data/

Thank you.

I ve a lot to read yet..

Bernd Alheit
Community Expert
Community Expert
October 19, 2021

The browser doesn't use Adobe Acrobat.

What happens when you open the file in Adobe Acrobat?

Armin5E0CAuthor
Participating Frequently
October 19, 2021

I tried in Adobe Acrobat but nothing happened.

Firefox is my default app for opening files with .pdf extension and if it s just a simple .pdf file it opens it without any issues.

Legend
October 19, 2021

Sure, but it (Firefox) does not use any Adobe tech. If you have problem with PDF in Firefox, you need to ask Firefox. Firefox are one of many RIVALS to Adobe in PDF. 

 

We can help you look at problem with Acrobat Pro and JavaScript. What do you see in the JavaScript debugger after "nothing happened"?

Armin5E0CAuthor
Participating Frequently
October 19, 2021

@JR BoulayCan you please take a look to above question if you have some time?
For now, I just d like to know if you can use forms in a PDF document that can submit data to webservice or create HTTP object with JS that submitts data. In the above code newdata contains e.g.: {"score":3}

The feedback form would look like this:

 

 

 

Highlighting the emojis onhover and set newdata value onclick is a next to do..