UNPKG

qz-tray

Version:

Connects a web client to the QZ Tray software. Enables printing and device communication from javascript.

1,387 lines (474 loc) 25.7 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Namespace: qz</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: qz</h1> <section> <header> <h2>qz</h2> </header> <article> <div class="container-overview"> <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#line1203">line 1203</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Namespaces</h3> <dl> <dt><a href="qz.api.html">api</a></dt> <dd></dd> <dt><a href="qz.configs.html">configs</a></dt> <dd></dd> <dt><a href="qz.file.html">file</a></dt> <dd></dd> <dt><a href="qz.hid.html">hid</a></dt> <dd></dd> <dt><a href="qz.networking.html">networking</a></dt> <dd></dd> <dt><a href="qz.printers.html">printers</a></dt> <dd></dd> <dt><a href="qz.security.html">security</a></dt> <dd></dd> <dt><a href="qz.serial.html">serial</a></dt> <dd></dd> <dt><a href="qz.socket.html">socket</a></dt> <dd></dd> <dt><a href="qz.usb.html">usb</a></dt> <dd></dd> <dt><a href="qz.websocket.html">websocket</a></dt> <dd></dd> </dl> <h3 class="subsection-title">Members</h3> <h4 class="name" id=".version"><span class="type-signature">(static, constant) </span>version<span class="type-signature"> :string</span></h4> <div class="description"> Version of this JavaScript library </div> <h5>Type:</h5> <ul> <li> <span class="param-type">string</span> </li> </ul> <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#line2954">line 2954</a> </li></ul></dd> </dl> <h3 class="subsection-title">Methods</h3> <h4 class="name" id=".print"><span class="type-signature">(static) </span>print<span class="signature">(configs, data, &hellip;arguments<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;(null|Error)>}</span></h4> <div class="description"> Send data to selected config for printing. The promise for this method will resolve when the document has been sent to the printer. Actual printing may not be complete. <p/> Optionally, print requests can be pre-signed: Signed content consists of a JSON object string containing no spacing, following the format of the "call" and "params" keys in the API call, with the addition of a "timestamp" key in milliseconds ex. <code>'{"call":"<callName>","params":{...},"timestamp":1450000000}'</code> </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>configs</code></td> <td class="type"> <span class="param-type">Object.&lt;Config></span> | <span class="param-type">Array.&lt;Object.&lt;Config>></span> </td> <td class="attributes"> </td> <td class="description last">Previously created config object or objects.</td> </tr> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">Array.&lt;(Object|string)></span> | <span class="param-type">Array.&lt;Array.&lt;(Object|string)>></span> </td> <td class="attributes"> </td> <td class="description last">Array of data being sent to the printer.<br/> String values are interpreted as <code>{type: 'raw', format: 'command', flavor: 'plain', data: &lt;string>}</code>. <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>data</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>type</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="description last">Printing type. Valid types are <code>[pixel | raw*]</code>. *Default</td> </tr> <tr> <td class="name"><code>format</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="description last">Format of data type used. *Default per type<p/> For <code>[pixel]</code> types, valid formats are <code>[html | image* | pdf]</code>.<p/> For <code>[raw]</code> types, valid formats are <code>[command* | html | image | pdf]</code>.</td> </tr> <tr> <td class="name"><code>flavor</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> </td> <td class="description last">Flavor of data format used. *Default per format<p/> For <code>[command]</code> formats, valid flavors are <code>[base64 | file | hex | plain* | xml]</code>.<p/> For <code>[html]</code> formats, valid flavors are <code>[file* | plain]</code>.<p/> For <code>[image]</code> formats, valid flavors are <code>[base64 | file*]</code>.<p/> For <code>[pdf]</code> formats, valid flavors are <code>[base64 | file*]</code>.</td> </tr> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last"> <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>language</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last">Required with <code>[raw]</code> type + <code>[html|image|pdf]</code> format. Printer language.</td> </tr> <tr> <td class="name"><code>quantization</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> "alpha" </td> <td class="description last">Optional with <code>[raw]</code> type + <code>[html|image|pdf]</code> format. The "black pixel" quantization method used. Valid values are <code>[alpha* | black | luma | dither]</code>.</td> </tr> <tr> <td class="name"><code>threshold</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 127 </td> <td class="description last">Optional with <code>[raw]</code> type + <code>[html|image|pdf]</code> format. The "black pixel" threshold used for quantization. Default is <code>127</code>.</td> </tr> <tr> <td class="name"><code>x</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 0 </td> <td class="description last">Optional with <code>[raw]</code> type + <code>[html|image|pdf]</code> format for language(s) <code>[cpcl|epl]</code>. The X position of the image.</td> </tr> <tr> <td class="name"><code>y</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 0 </td> <td class="description last">Optional with <code>[raw]</code> type + <code>[html|image|pdf]</code> format for language(s) <code>[cpcl|epl]</code>. The Y position of the image.</td> </tr> <tr> <td class="name"><code>dotDensity</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> "single" </td> <td class="description last">Optional with <code>[raw]</code> type + <code>[html|image|pdf]</code> format for language(s) <code>[escpos]</code>. Valid values are <code>[single* | double | triple | single-legacy | double-legacy]</code> or the escpos "decimal" equivalent</td> </tr> <tr> <td class="name"><code>imageEncoding</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> "esc_asterisk" </td> <td class="description last">Optional with <code>[raw]</code> type + <code>[html|image|pdf]</code> format for language(s) <code>[escpos]</code> and imageEncoding(s) <code>esc_asterisk</code>. Valid values are <code>[esc_asterisk* | gs_l | gs_v_0]</code>.</td> </tr> <tr> <td class="name"><code>precision</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 128 </td> <td class="description last">Optional with <code>[raw]</code> type <code>[html|image|pdf]</code> format for language(s) <code>[evolis]</code>. Bit precision of the ribbons.</td> </tr> <tr> <td class="name"><code>overlay</code></td> <td class="type"> <span class="param-type">boolean</span> | <span class="param-type">string</span> | <span class="param-type">Array.&lt;Array.&lt;number>></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> false </td> <td class="description last">Optional with <code>[raw]</code> type <code>[html|image|pdf]</code> format for language(s) <code>[evolis]</code>. Instructions for printing the "clear" overlay ribbon. Boolean sets entire layer, string sets mask image, Array sets array of rectangles in format <code>[x1,y1,x2,y2]</code>.</td> </tr> <tr> <td class="name"><code>logoId</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last">Mandatory with <code>[raw]</code> type <code>[html|image|pdf]</code> format for language(s) <code>[pgl]</code>. Logo identifier to append for storing in the printer's memory.</td> </tr> <tr> <td class="name"><code>igpDots</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> false </td> <td class="description last">Optional with <code>[raw]</code> type <code>[html|image|pdf]</code> format for language(s) <code>[pgl]</code>. When set to <code>true</code> instructs printer to fallback to legacy 60x72 dpi when printing graphics</td> </tr> <tr> <td class="name"><code>xmlTag</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last">Required with <code>[xml]</code> flavor. Tag name containing base64 formatted data.</td> </tr> <tr> <td class="name"><code>pageWidth</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last">Optional with <code>[html | pdf]</code> formats. Width of the rendering. Defaults to paper width.</td> </tr> <tr> <td class="name"><code>pageHeight</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last">Optional with <code>[html | pdf]</code> formats. Height of the rendering. Defaults to paper height for <code>[pdf]</code>, or auto sized for <code>[html]</code>.</td> </tr> <tr> <td class="name"><code>pageRanges</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last">Optional with <code>[pdf]</code> formats. Comma-separated list of page ranges to include.</td> </tr> <tr> <td class="name"><code>ignoreTransparency</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> false </td> <td class="description last">Optional with <code>[pdf]</code> formats. Instructs transparent PDF elements to be ignored. Transparent PDF elements are known to degrade performance and quality when printing.</td> </tr> <tr> <td class="name"><code>altFontRendering</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> false </td> <td class="description last">Optional with <code>[pdf]</code> formats. Instructs PDF to be rendered using PDFBOX 1.8 techniques. Drastically improves low-DPI PDF print quality on Windows.</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> <tr> <td class="name"><code>arguments</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="attributes"> &lt;optional><br> &lt;repeatable><br> </td> <td class="description last">Additionally three more parameters can be specified:<p/> <code>{boolean} [resumeOnError=false]</code> Whether the chain should continue printing if it hits an error on one the the prints.<p/> <code>{string|Array<string>} [signature]</code> Pre-signed signature(s) of the JSON string for containing <code>call</code>, <code>params</code>, and <code>timestamp</code>.<p/> <code>{number|Array<number>} [signingTimestamps]</code> Required to match with <code>signature</code>. Timestamps for each of the passed 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#line1701">line 1701</a> </li></ul></dd> <dt class="tag-see">See:</dt> <dd class="tag-see"> <ul> <li><a href="qz.configs.html#.create">qz.configs.create</a></li> </ul> </dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Promise.&lt;(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>