qz-tray
Version:
Connects a web client to the QZ Tray software. Enables printing and device communication from javascript.
1,697 lines (477 loc) • 22.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Namespace: printers</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Namespace: printers</h1>
<section>
<header>
<h2>
<span class="ancestors"><a href="qz.html">qz</a>.</span>printers</h2>
</header>
<article>
<div class="container-overview">
<div class="description">Calls related to getting printer information from the connection.</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1420">line 1420</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".clearQueue"><span class="type-signature">(static) </span>clearQueue<span class="signature">(options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<(null|Error)>}</span></h4>
<div class="description">
Clear the queue of a specified printer or printers. Does not delete retained jobs.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">string</span>
|
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Name of printer to clear
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>printerName</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Name of printer to clear</td>
</tr>
<tr>
<td class="name"><code>jobId</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Cancel a job of a specific JobId instead of canceling all. Must include a printerName.</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-since">Since:</dt>
<dd class="tag-since"><ul class="dummy"><li>2.2.4</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1504">line 1504</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<(null|Error)></span>
</dd>
</dl>
<h4 class="name" id=".details"><span class="type-signature">(static) </span>details<span class="signature">()</span><span class="type-signature"> → {Promise.<(Array.<Object>|Object|Error)>}</span></h4>
<div class="description">
Provides a list, with additional information, for each printer available to QZ.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1458">line 1458</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<(Array.<Object>|Object|Error)></span>
</dd>
</dl>
<h4 class="name" id=".find"><span class="type-signature">(static) </span>find<span class="signature">(query<span class="signature-attributes">opt</span>, signature<span class="signature-attributes">opt</span>, signingTimestamp<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<(Array.<string>|string|Error)>}</span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>query</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Search for a specific printer. All printers are returned if not provided.</td>
</tr>
<tr>
<td class="name"><code>signature</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Pre-signed signature of hashed JSON string containing <code>call='printers.find'</code>, <code>params</code>, and <code>timestamp</code>.</td>
</tr>
<tr>
<td class="name"><code>signingTimestamp</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Required with <code>signature</code>. Timestamp used with pre-signed content.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1447">line 1447</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
The matched printer name if <code>query</code> is provided.
Otherwise an array of printer names found on the connected system.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<(Array.<string>|string|Error)></span>
</dd>
</dl>
<h4 class="name" id=".getDefault"><span class="type-signature">(static) </span>getDefault<span class="signature">(signature<span class="signature-attributes">opt</span>, signingTimestamp<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<(string|Error)>}</span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>signature</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Pre-signed signature of hashed JSON string containing <code>call='printers.getDefault</code>, <code>params</code>, and <code>timestamp</code>.</td>
</tr>
<tr>
<td class="name"><code>signingTimestamp</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Required with <code>signature</code>. Timestamp used with pre-signed content.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1433">line 1433</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Name of the connected system's default printer.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<(string|Error)></span>
</dd>
</dl>
<h4 class="name" id=".getStatus"><span class="type-signature">(static) </span>getStatus<span class="signature">()</span><span class="type-signature"> → {Promise.<(null|Error)>}</span></h4>
<div class="description">
Retrieve current printer status from any active listeners.
</div>
<dl class="details">
<dt class="tag-since">Since:</dt>
<dd class="tag-since"><ul class="dummy"><li>2.1.0</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1537">line 1537</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="qz.printers.html#.startListening">qz.printers.startListening</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<(null|Error)></span>
</dd>
</dl>
<h4 class="name" id=".setPrinterCallbacks"><span class="type-signature">(static) </span>setPrinterCallbacks<span class="signature">(calls)</span><span class="type-signature"></span></h4>
<div class="description">
List of functions called for any printer status change.
Event data will contain <code>{string} printerName</code> and <code>{string} status</code> for all types.
For RECEIVE types, <code>{Array} output</code> (in hexadecimal format).
For ERROR types, <code>{string} exception</code>.
For ACTION types, <code>{string} actionType</code>.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>calls</code></td>
<td class="type">
<span class="param-type">function</span>
|
<span class="param-type">Array.<function()></span>
</td>
<td class="description last">Single or array of <code>Function({Object} eventData)</code> calls.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-since">Since:</dt>
<dd class="tag-since"><ul class="dummy"><li>2.1.0</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1553">line 1553</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".startListening"><span class="type-signature">(static) </span>startListening<span class="signature">(printers, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<(null|Error)>}</span></h4>
<div class="description">
Start listening for printer status events, such as paper_jam events.
Reported under the ACTION type in the streamEvent on callbacks.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>printers</code></td>
<td class="type">
<span class="param-type">null</span>
|
<span class="param-type">string</span>
|
<span class="param-type">Array.<string></span>
</td>
<td class="attributes">
</td>
<td class="description last">Printer or list of printers to listen to, null listens to all.</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
|
<span class="param-type">null</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Printer listener options
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>jobData</code></td>
<td class="type">
<span class="param-type">null</span>
|
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">Flag indicating if raw spool file content should be return as well as status information (Windows only)</td>
</tr>
<tr>
<td class="name"><code>maxJobData</code></td>
<td class="type">
<span class="param-type">null</span>
|
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
-1
</td>
<td class="description last">Maximum number of bytes to returns for raw spooled file content (Windows only)</td>
</tr>
<tr>
<td class="name"><code>flavor</code></td>
<td class="type">
<span class="param-type">null</span>
|
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
"plain"
</td>
<td class="description last">Flavor of data format returned. Valid flavors are <code>[base64 | hex | plain*]</code> (Windows only)</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-since">Since:</dt>
<dd class="tag-since"><ul class="dummy"><li>2.1.0</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1479">line 1479</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="qz.printers.html#.setPrinterCallbacks">qz.printers.setPrinterCallbacks</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<(null|Error)></span>
</dd>
</dl>
<h4 class="name" id=".stopListening"><span class="type-signature">(static) </span>stopListening<span class="signature">()</span><span class="type-signature"> → {Promise.<(null|Error)>}</span></h4>
<div class="description">
Stop listening for printer status actions.
</div>
<dl class="details">
<dt class="tag-since">Since:</dt>
<dd class="tag-since"><ul class="dummy"><li>2.1.0</li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="qz-tray.js.html">qz-tray.js</a>, <a href="qz-tray.js.html#line1523">line 1523</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="qz.printers.html#.setPrinterCallbacks">qz.printers.setPrinterCallbacks</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<(null|Error)></span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="qz.html">qz</a></li><li><a href="qz.api.html">api</a></li><li><a href="qz.configs.html">configs</a></li><li><a href="qz.file.html">file</a></li><li><a href="qz.hid.html">hid</a></li><li><a href="qz.networking.html">networking</a></li><li><a href="qz.printers.html">printers</a></li><li><a href="qz.security.html">security</a></li><li><a href="qz.serial.html">serial</a></li><li><a href="qz.socket.html">socket</a></li><li><a href="qz.usb.html">usb</a></li><li><a href="qz.websocket.html">websocket</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Thu Apr 02 2026 13:01:02 GMT-0400 (Eastern Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>