1

I try to make a static simple page using HTML, JS, QZ-Tray that can print a mock data into LQ-310 printer.

I've been follow how to sign in JS from QZ-Tray wiki. However, I still have pop up message like below: enter image description here

I've changed the flow from server side to client side to sign and remove this pop up, but it has no effect

NOTE:

Rusydy
  • 53
  • 5
  • Hmmm... The signature popup actually looks correct! If the call to setCertificatePromise() is not defined, it may order of operations. Does it work if you move it before your other QZ calls? – tresf Oct 12 '22 at 21:31
  • Nevermind the above question, order of operations looks fine. I've posted my results in a new answer below including the error message I receive and how to get the pop-up to go away. – tresf Oct 13 '22 at 01:53

1 Answers1

1

The project works just fine on my computer. These are the steps I ran:

  1. Clone the code:
    git clone https://github.com/Rusydy/print-qz-static
    
  2. Extract the certificate file used for signing messages by removing the quotes and newlines from the x509 certificate in qz-cert.js and saving it as certificate.crt.
  3. Install and open QZ Tray
  4. Open the Site Manager dialog in QZ Tray (QZ Tray icon, Advanced, Site Manager)
  5. Drag-and-drop the certificate.crt file into the Site Manager dialog.
  6. Open index.html, click "Test printer"

I did receive a JavaScript error, however it did not result in a pop-up warning dialog. The document prints first time, no pop-ups.

enter image description here

qz-cert.js:27 Uncaught TypeError: Cannot read properties of undefined (reading 'then')
    at qz-cert.js:27:3

This error message is fairly benign, but it's because you're using a .then(...) on your setCertificatePromise() call here. The function call setCertificatePromise() does not return a promise, so any error detection must be internal (e.g. manually throw an exception raised by fetch() or $.ajax(), etc when loading this certificate from a URL). Since you're loading the certificate from a string value, no exception handling is needed, but regardless, .then() must be removed from this file to remove the error.

In regards to the pop-up you are receiving, this is a sign that the certificate you've created hasn't been installed into QZ Tray. You may drag-and drop it into the Site Manager dialog to install it to your system (or manually by copying it to <appdir>\override.crt and restarting QZ Tray).

tresf
  • 7,103
  • 6
  • 40
  • 101
  • 1
    Thank you very much, @tresf! Now I can print with no error or pop-up. – Rusydy Oct 14 '22 at 18:39
  • source link not working any help – gopal Feb 05 '23 at 09:39
  • All of my links still exist. The one you're asking about was copy and pasted from the original question, so please comment there or ask in a brand new question, I'd be happy to help! – tresf Feb 05 '23 at 17:17