0

I am using Xubuntu 16.04. I was unable to properly configure the drivers for a Xerox 7545 to print with a Default Group account setup. However, I am able to print by saving my document as a PDF. Then I can go to the IP address of the printer in the browser. There I can submit a web form for printing.

I would like to integrate a cURL command into a script to make the printing process more efficient. I am confident that my cURL syntax is good. (I was able to successfully print to a different printer.)

curl -F "frmFileUpload=@/home/brock/Desktop/example.pdf" -F "frmUserId=####" http://###.##.##.###/print/print.php?submitted=true

However, I believe my print job keeps getting deleted. On the webpage where you submit the print job, there is this message: "Note: Please wait for Job Submission confirmation window before navigating to another page. Otherwise, job will be deleted."

When I submit on the webpage, the page loads (for the form to submit). Then a small dialog box pops up:

enter image description here

The submission page has two <form></form> sections. The following contains the file upload field.

<form enctype="multipart/form-data" action="/upload/xerox.set" method="post">

This following contains the User ID field, number of copies, etc.

<form action="#" method="post">

Here is the submit button.

<button type="button" onclick="SubmitForm();">Submit Job</button>

Here is the source code for the SubmitForm() function. The function begins on line 144 and ends on line 482.

When I submit the form using cURL and I later run echo $? it returns 0 for no error. I have tried using the two other action URLs as well as the URL of the page itself. The URL in the command above is from doing inspect element and viewing the network tab during submission.

I think the issue is this: "Note: Please wait for Job Submission confirmation window before navigating to another page. Otherwise, job will be deleted."

I disabled javascript in my browser. I then tried to submit, and the submission would not load. Javascript running on the submission page is obviously a requisite for it to submit. Is there a way around this? Any comments or ideas are appreciated. Thanks

1

That popup saying that "The job has been submitted for printing" is a JavaScript alert popup, and there is no way to acknowledge the alert through JS, although you can override the default alert action - see here.

I see that you attempted to obtain the action URL from the form, and that gave me an idea - can you find the function definition of the function that the submit button calls? The submit button's onclick action is called SubmitForm(), so see if you can find it in the source code and reproduce it in cURL.

  • I did find the SubmitForm() source code, but I believe cURL can't handle javascript. I've seen it talked about on a few posts. I wonder if there is an option alternative to cURL. – jbrock Mar 23 '17 at 17:10
  • Right, but given the source code, you can see exactly what the request needs, and build the cURL request with that info. Or, you can write a simple script in JS and run it in Node.js. Can you post the source? – joepin Mar 23 '17 at 19:09
  • It has been posted in my question above. Thank you – jbrock Mar 23 '17 at 22:28
  • Hmm I just went through that function: basically, when you click submit, this function gets all the parameters for printing, validates them, and puts them into a form, which gets sent as part of the request to the printer. I'm thinking now that at least some of these fields are required in order to print, so you may have to include them in the cURL request? The only other alternative I can think of is that you must acknowledge the "Job Submitted" alert, which, though I have little experience designing printers, I think to be highly unlikely. – joepin Mar 26 '17 at 6:15
  • (In case you're interested, the code from the submitForm function sheds some light on the two <form> elements on the submission page. For whatever reason, the developers made an entry form, where the user enters all the data, (this is probably the form you see on the page), and a hidden form that is used for submission. It is the action method on this second form that you're interested in, as this form is the one that gets submitted.) – joepin Mar 26 '17 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.