silent printing not working. javascript coding issue?

472 views
Skip to first unread message

dtma...@hotmail.co.uk

unread,
Jan 11, 2017, 7:48:16 AM1/11/17
to qz-print
Hi

I have finally got the certificates installed correctly... I think.

I can now suppress the dialogue to connect to QZTray with the installed certificate, however I cannot suppress the find printer and print dialogues.
I have found this is the same on the sample.html and the website so presume there is a bit more javascript trickery to be done somewhere. I have searches the fourum google and wiki for answers my last hope is to ask here for help.


<CODE>
qz.security.setCertificatePromise(function(resolve, reject) {

$.ajax("/assets/signing/digital-certificate.txt?foo").then(resolve, reject);

});


qz.security.setSignaturePromise(function(toSign) {
return function(resolve, reject) {
$.post("/assets/signing/sign-message", {request: toSign}).then(resolve, reject);
};
});


function testprint() {
qz.websocket.connect().then(function() {
return qz.printers.find("zebra") // Pass the printer name into the next Promise
}).then(function(printer) {
var config = qz.configs.create(printer); // Create a default config for the found printer
var data = ['^XA^FO50,50^ADN,36,20^FDRAW ZPL EXAMPLE^FS^XZ']; // Raw ZPL
return qz.print(config, data);
}).catch(function(e) { console.error(e); });

}

function startConnection(config) {
if (!qz.websocket.isActive()) {
updateState('Waiting', 'default');

qz.websocket.connect(config).then(function() {
updateState('Active', 'success');
findVersion();
}).catch(handleConnectionError);
} else {
displayMessage('An active connection with QZ already exists.', 'alert-warning');
}
}

</CODE>


The "function startConnection" is called via a button and can be suppressed but "function testprint" is not being signed properly. from the debug data it appears there is no data being sent to sign any ideas or help would be greatly appreciated with this

many thanks

dtma...@hotmail.co.uk

unread,
Jan 11, 2017, 8:45:57 AM1/11/17
to qz-print
Maybe I should ask this...

How do I suppress the print dialogue. I have done everything mentioned in https://github.com/qzind/tray/wiki/2.0-signing-messages
using the code given in the sample.html I am able to suppress the initial connection dialogue as the certificate seems to be installed.
I have failed to suppress the print dialogue on the original sample.html
at https://demo.qz.io/ and on my own website.
I have looked everywhere to find the correct code to enable me to do this and it seems to be the simple fact that the print requests are not signed presumably it is something that needs changing in the Javascript to sign the request. How do I achieve this? I know simple PHP but never got to grips with Javascript?

dtma...@hotmail.co.uk

unread,
Jan 11, 2017, 9:33:08 AM1/11/17
to qz-print, dtma...@hotmail.co.uk
OK Ignore or delete this question. Got it working. it was a problem with the way my server was rendering the signing.php page. not a problem with the coding or program.

Tres Finocchiaro

unread,
Jan 11, 2017, 4:39:01 PM1/11/17
to Dave Thurstans, qz-print
Dave,

Thanks for the update.
On Wed, Jan 11, 2017 at 9:33 AM, <dtma...@hotmail.co.uk> wrote:
OK Ignore or delete this question. Got it working. it was a problem with the way my server was rendering the signing.php page. not a problem with the coding or program.

--
You received this message because you are subscribed to the Google Groups "qz-print" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages