javascriptprintingqz-tray

TypeError: qz.security.setCertificatePromise(...) is undefined


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:


Solution

  • 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).