Errors trying to find a printer

826 views
Skip to first unread message

CrossingTheVeil

unread,
Mar 28, 2016, 2:29:57 PM3/28/16
to qz-print
Giving my difficulties in trying to get my own keys to work, I decided to atleast try to print with prompts to see if this software will do what I need it to do.

So I copied and pasted the bare bones start code and I get this error message:

TypeError: _qz.tools.hash is not a function

I do not know what is going wrong, I have all the required js files connected, etc.

I have a script block at the bottom of the page to initialize things:

<script type="text/javascript">
qz.security.setCertificatePromise(function(resolve, reject) {
//Preferred method - from server
//$.ajax("assets/signing/public-key.txt").then(resolve, reject);
//$.ajax("assets/signing/www.example.com.cert.pem").then(resolve, reject);

//Alternate method 1 - anonymous
resolve();
});
qz.security.setSignaturePromise(function(toSign) {
return function(resolve, reject) {
//Preferred method - from server
// $.ajax("/secure/url/for/sign-message?request=" + toSign).then(resolve, reject);
//$.ajax("../js/qztray/assets/signing/sign-message.php?request=" + toSign).then(resolve, reject);

//Alternate method - unsigned
resolve();
}
});

</script>

And then in my $j(document).ready() I have:

qz.websocket.connect().then(function() {
alert("Connected!");
return qz.printers.find("zebra")
}).then(function(){ alert('next')});

And that is it. I get the connected alert but then I get the error listed above.

Tres Finocchiaro

unread,
Mar 28, 2016, 2:43:31 PM3/28/16
to CrossingTheVeil, qz-print
TypeError: _qz.tools.hash is not a function

You need to include sha256-min.js per: https://qz.io/wiki/2.0-Getting-Started#the-code 

--
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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

CrossingTheVeil

unread,
Mar 28, 2016, 2:50:00 PM3/28/16
to qz-print, minifir...@crossingtheveil.com
I have them loaded:

<script type="text/javascript" src="../js/qztray/qz-tray.js"></script>
<script type="text/javascript" src="../js/qztray/dependencies/rsvp-3.1.0.min.js"></script>
<script type="text/javascript" src="../js/qztray/dependencies/sha-256.min.js"></script>

And I even added an alert(); into the sha-256 just to make sure it loaded, and it popped up the alert.

CrossingTheVeil

unread,
Mar 28, 2016, 2:52:40 PM3/28/16
to qz-print
Of course, I had them in the exactly opposite loading order. I put them in the order they need to be and it is all good now.

Thanks

PS - Dyslexia can make coding slow sometimes.

Tres Finocchiaro

unread,
Mar 28, 2016, 2:54:19 PM3/28/16
to CrossingTheVeil, qz-print
Terrific.  Let us know if you have any other question or concerns.

delan...@gmail.com

unread,
May 3, 2017, 12:33:07 PM5/3/17
to qz-print, minifir...@crossingtheveil.com
Hi Tres,
I am using qz tray 2.0.3 and also getting TypeError: _qz.tools.hash is not a function error message.

Please see below,
head>
<meta charset="UTF-8">
<script type="text/javascript" src="scripts/qzTray/js/dependencies/rsvp-3.1.0.min.js"></script>
<script type="text/javascript" src="scripts/qzTray/js/dependencies/sha-256.min.js"></script>
<script type="text/javascript" src="scripts/qzTray/js/qz-tray.js"></script>

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


resolve();
});

qz.security.setSignaturePromise(function(toSign) {
return function(resolve, reject) {

resolve();
}
});


function setInitState(){
qz.websocket.connect().then(function() {
return qz.printers.find('zebra')
}).then(function(printer) {
var config = qz.configs.create(printer);
var airbills = document.getElementById('airbills').value;
var imageData = document.getElementById('imageData' + airbills).value;
var data = [{
type: 'raw',
format: 'base64',
data: imageData
}];

return qz.print(config, data);
}).catch(function(e) {
//console.error(e);
alert(e);
});
}

</script>
</head>

is there anything wrong in my code?

Thanks a lot,

delan...@gmail.com

unread,
May 3, 2017, 12:35:16 PM5/3/17
to qz-print, minifir...@crossingtheveil.com, delan...@gmail.com
more error message details:

TypeError: _qz.tools.hash is not a function. (In '_qz.tools.hash(_qz.tools.stringify(signObj))', '_qz.tools.hash' is null)

Thanks again

Tres Finocchiaro

unread,
May 3, 2017, 12:41:38 PM5/3/17
to delan...@gmail.com, qz-print, CrossingTheVeil
This is a sign that the software could not locate sha256 or that the HTML page does not have UTF8 enabled.


<script type="text/javascript" src="scripts/qzTray/js/dependencies/sha-256.min.js"></script>
--
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.

delan...@gmail.com

unread,
May 3, 2017, 12:51:15 PM5/3/17
to qz-print, delan...@gmail.com, minifir...@crossingtheveil.com
Thank you very much Tres.

I have <meta charset="UTF-8"> included in <head>

and I can see sha-256.min.js content in browser developer tool resource window

what else could go wrong?
> To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+u...@googlegroups.com.

delan...@gmail.com

unread,
May 3, 2017, 1:10:57 PM5/3/17
to qz-print, delan...@gmail.com, minifir...@crossingtheveil.com
I fixed the issue by adding <%@ page contentType="text/html; charset=UTF-8" %> to my jsp page.

Thanks for your help.

Tres Finocchiaro

unread,
May 3, 2017, 1:33:05 PM5/3/17
to delan...@gmail.com, qz-print, CrossingTheVeil
Thanks for the information!
To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages