When I run the sample text file, a message is get displayed as "Printer is not identified" then I selected the printer through the option 'Find Default Printer'. How do I set my localhost printer as default and the same to be used throughout my application. Do I need to make any changes in the code and guide me on setup method.
var defaultPrinter; window.onload = function() { qz.websocket.connect() .then(qz.printers.getDefault) .then(function(printer) { defaultPrinter = printer; }) .catch(function(e) { console.error(e); }); } // Called by a button function printSomething() { if (defaultPrinter) { var config = qz.configs.create(defaultPrinter, { /* opts */ }); qz.print(config, [ /* my data to print */ ]); } else { alert("Could not detect printer."); } }
What will be your best offer?
So symmarizing everything in one place:
1) generate your private key and certificate by running command like this:
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3650 -nodes
You have either to install openssl for windows or cygwin or just use linux system.
Finally you'll have 2 files:
key.pem - which is private key
and cert.pem - which I guess is public certificate (you can rename it to cert.pem.crt and see its details by windows certificate viewer)
2) Either compile your own build
https://qz.io/wiki/compiling using your certificate cert.pem.crt
The final build command is
ant nsis -Dauthcert.use=ant/cert/cert.pem.crt (place your certificate in appropriate folder)
OR
run your existing installed QzTray using your certificate (using bat file)
javaw -DtrustedRootCert=D:\projects\cert.pem.crt -jar "d:\Install\Progs\Qz\qz-tray.jar"
3) Using qz demo samples - update setCertificatePromise
with something like this
$.ajax("http://domian.dev/qz/certificate.cer").then(resolve, reject);
or $.ajax("http://domian.dev/qz/certificate.cer.txt").then(resolve, reject);
and make sure the web url is accessible as direct link ( http://domian.dev/qz/certificate.cer.txt )
4) Update setSignaturePromise with
$.ajax(" http://domian.dev/qz/sign-message.php?request=" + toSign).then(resolve, reject);
In sign-message.php
use your private.key you've generated at step 1
$KEY = 'key.pem'; // for your security place the private key in non-accessible directory from web
$PASS = '';
$req = $_GET['request'];
$privateKey = openssl_get_privatekey(file_get_contents($KEY), $PASS);
//.........