Axional
JavaScript library provides a CUPS
client interface to interact with CUPS
print servers.
CUPS
(formerly an acronym for Common UNIX Printing System) is a modular printing system for Unix-like computer operating systems which allows a computer to act as a print server. A computer running CUPS
is a host that can accept print jobs from client computers, process them, and send them to the appropriate printer.
CUPS
consists of a print spooler and scheduler, a filter system that converts the print data to a format that the printer will understand, and a backend system that sends this data to the print device. CUPS
uses the Internet Printing Protocol (IPP) as the basis for managing print jobs and queues. It also provides the traditional command line interfaces for the System V and Berkeley print systems, and provides support for the Berkeley print system's Line Printer Daemon protocol and limited support for the server message block (SMB) protocol. System administrators can configure the device drivers which CUPS
supplies by editing text files in Adobe's PostScript Printer Description (PPD) format. There are a number of user interfaces for different platforms that can configure CUPS
, and it has a built-in web-based interface. CUPS
is free software, provided under the Apache License.
A machine that sends jobs to another machine for printing is called a client and the machine that accepts the job is called a print server. A client can also be a print server if it is directly connected to a printer.
One of the biggest advantages of CUPS
is that it allows you to set up a universal print server which can work with almost all printer connection types and most of the printing protocol. The following figure shows that CUPS
doesn't only accept print jobs from a local application, but also support the clients working on different platforms.
1 CUPS client
CupsClient class allows to connect to a local or remote CUPS
Server, discover and manage queues, print data and manage printing jobs.
Return | Method | Description |
---|---|---|
PrintRequestResult | print(String printerName, String data) | . |
PrintRequestResult | print(String printerName, Object data) | . |
PrintRequestResult | print(String printerName, String data, Consumer configurator) | . |
PrintRequestResult | print(String printerName, Object data, Consumer configurator) | . |
boolean | holdJob(int jobID) | . |
boolean | releaseJob(int jobID) | . |
boolean | cancelJob(int jobID) | . |
List<PrintJobAttributes> | getJobs(String printerName) | . |
List<CupsPrinter> | getPrinters() | . |
CupsPrinter | getPrinter(String printerName) | . |
You can create a CUPS
client instance by providing it's host address. By default,
port 631 and os user will be used.
<script> var cups = new Ax.net.CupsClient('192.168.100.20'); console.log(cups); </script>
http://axional:192.168.100.20:631
2 List printers
To list printers call listPrinters
method.
<script> var cups = new Ax.net.CupsClient('192.168.100.20', 631); // List printers for (var p of cups.getPrinters()) { console.log(p); console.log("URL:" + p.getPrinterURL() + " isDefault:" + p.isDefault() + " name:" + p.getName() + " location:" + p.getLocation() + " description:" + p.getDescription() + " mediaDefault:" + p.getMediaDefault() + " resolution:" + p.getResolutionDefault() + " colormode:" + p.getColorModeDefault() + " make&model:" + p.getPrinterMakeAndModel() + " state:" + p.getPrinterState() + " statereason:" + p.getPrinterStateReasons() + " printerCurrentTime:" + p.getPrinterCurrentTime() + " pageRangesSupported:" + p.getPageRangesSupported() ); } </script>
BIXOLON-SLP-TX400
BrGenML1
BROTHER_BN
BROTHER_COLOR
CITIZEN_CL-S400DTZ
Cups-PDF
Zebra_Printer
Zebra_ZTC_QLn420
3 Get printer attributes
For a given printer you can inspect it's attributes.
3.1 Printer description
<script> var cups = new Ax.net.CupsClient('192.168.100.20'); console.log(cups.getPrinter('BROTHER_BN').getDescription()); </script>
Printer B/N (Brother MFC7860DW)
3.2 Supported media types
<script> var cups = new Ax.net.CupsClient('192.168.100.20'); for (var m of cups.getPrinter('BROTHER_BN').getMimeTypesSupported()) console.log(m); </script>
application/octet-stream
application/pdf
application/postscript
application/vnd.adobe-reader-postscript
application/vnd.cups-command
application/vnd.cups-pdf
application/vnd.cups-pdf-banner
application/vnd.cups-postscript
application/vnd.cups-raw
application/x-cshell
application/x-csource
application/x-perl
application/x-shell
image/gif
image/jpeg
image/png
image/tiff
image/x-bitmap
image/x-photocd
image/x-portable-anymap
image/x-portable-bitmap
image/x-portable-graymap
image/x-portable-pixmap
image/x-sgi-rgb
image/x-sun-raster
image/x-xbitmap
image/x-xpixmap
image/x-xwindowdump
text/css
text/html
text/plain
3.3 Get printers info
You can generate a CUPS
printer list producing a table using a ResultSet.
<script> var cups = new Ax.net.CupsClient('192.168.100.20'); // for each printer store all it's attributes as an array var rows = []; for (var p of cups.getPrinters()) { rows.push([ p.getName(), p.getDescription(), p.getLocation(), p.getPrinterMakeAndModel(), p.getPrinterState(), p.getPrinterStateReasons(), ]); } // Return as a resultset return new Ax.rs.Reader().build(rows, options => { options.setColumnNames([ "Queue name", "Description", "Location", "Make and Model", "State", "Reasons" ] ); }); </script>
+--------------------+------------------------------------+----------------+--------------------------------------------------------------------------------------------------+-------+---------------------+
|<null> |<null> |<null> |<null> |<null> |<null> |
|Queue name |Description |Location |Make and Model |State |Reasons |
|char(20) |char(36) |char(16) |char(98) |char(7)|char(21) |
+--------------------+------------------------------------+----------------+--------------------------------------------------------------------------------------------------+-------+---------------------+
|BIXOLON-SLP-TX400 |BIXOLON-SLP-TX400 |Sala Admin |Local Raw Printer |idle |none |
|BrGenML1 |BrGenML1 | |Brother BrGenML1 for CUPS |idle |none |
|BROTHER_BN |Printer B/N (Brother MFC7860DW) |Sala admin |Brother MFC7860DW for CUPS |idle |opc-life-over-warning|
|Brother_DCP-L8410CDW|Brother_DCP-L8410CDW |Sala Admin 2 |Brother DCP-L8410CDW CUPS |idle |none |
|Brother_MFC7860DW |Brother_MFC7860DW |Sala Admin 1 |Brother MFC7860DW for CUPS |stopped|opc-life-over-warning|
|CITIZEN_CL-S400DTZ |CITIZEN CL-S400DTZ | |Local Raw Printer |idle |none |
|Cups-PDF |Cups-PDF | |Generic CUPS-PDF Printer |idle |none |
|EPSON_TMM30 |EPSON TM M30 P1 | |EPSON TM-m30 (rastertotmt) |idle |none |
|EpsonTorras |EpsonTorras |EpsonTorras |EPSON TM-m30 (rastertotmt) |idle |none |
|EpsonWF4720 |EpsonWF4720 |Sala Admin 1 |Epson WF-4720 Series - epson-inkjet-printer-escpr2 1.1.8-1lsb3.2 (Seiko Epson Corporation LSB 3.2)|idle |none |
|MFC7860DW |MFC7860DW | |Brother MFC7860DW for CUPS |idle |none |
|MunBynBaqueira |MunBynBaqueira |Development Room|POS-80 |idle |none |
|Zebra-Baqueira-2844 |Zebra-Baqueira-2844 |Deister |Zebra EPL2 Label Printer, 1.3 |idle |none |
|Zebra_Printer |Zebra Printer | |Zebra ZPL Label Printer |idle |none |
|Zebra_ZTC_QLn420 |Zebra Technologies ZTC QLn420 (CPCL)| |Local Raw Printer |stopped|paused |
+--------------------+------------------------------------+----------------+--------------------------------------------------------------------------------------------------+-------+---------------------+
3.4 Get all printer attributes
We can easily inspect all printer attributes. The following example constructs a table using SQL ResultSet for all printers and it's attributes.
<script> var cups = new Ax.net.CupsClient('192.168.100.20'); // for each printer store all it's attributes as an array var rows = []; for (var p of cups.getPrinters()) { rows.push([ p.getName(), p.getDescription(), p.getLocation(), p.getPrinterMakeAndModel(), p.getPrinterState(), p.getPrinterStateReasons(), p.getMediaDefault(), p.getMediaSupported(), p.getResolutionDefault(), p.getResolutionSupported(), p.getColorModeDefault(), p.getColorModeSupported(), p.getSidesDefault(), p.getSidesSupported(), p.getNumberUpDefault(), p.getNumberUpSupported(), p.getMimeTypesSupported(), p.getPageRangesSupported(), p.getCopiesSupported(), p.getOrientationRequestedSupported() ]); } // Return as a resultset return new Ax.rs.Reader().build(rows, options => { options.setColumnNames([ "Name", "Description", "Location", "MakeAndModel", "State", "Reasons", "MediaDefault", "MediaSupported", "ResolutionDefault", "ResolutionSupported", "ColorModeDefault", "ColorModeSupported", "SidesDefault", "SidesSupported", "NumberUpDefault", "NumberUpSupported", "MimeTypesSupported", "PageRangesSupported", "CopiesSupported", "OrientationRequestedSupported" ] ); }); </script>
+--------------------+------------------------------------+----------------+--------------------------------------------------------------------------------------------------+-------+---------------------+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------+---------------------------------------------------------------------------------------------+----------------+-------------------+------------+------------------------------------------------------+---------------+-------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------+---------------+----------------------------------------------------------+
|<null> |<null> |<null> |<null> |<null> |<null> |<null> |<null> |<null> |<null> |<null> |<null> |<null> |<null> |<null> |<null> |<null> |<null> |<null> |<null> |
|Name |Description |Location |MakeAndModel |State |Reasons |MediaDefault |MediaSupported |ResolutionDefault|ResolutionSupported |ColorModeDefault|ColorModeSupported |SidesDefault|SidesSupported |NumberUpDefault|NumberUpSupported |MimeTypesSupported |PageRangesSupported|CopiesSupported|OrientationRequestedSupported |
|char(20) |char(36) |char(16) |char(98) |char(7)|char(21) |char(31) |char(0) |char(10) |char(0) |char(10) |char(0) |char(9) |char(0) |char(1) |char(0) |char(0) |char(4) |char(0) |char(0) |
+--------------------+------------------------------------+----------------+--------------------------------------------------------------------------------------------------+-------+---------------------+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------+---------------------------------------------------------------------------------------------+----------------+-------------------+------------+------------------------------------------------------+---------------+-------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------+---------------+----------------------------------------------------------+
|BIXOLON-SLP-TX400 |BIXOLON-SLP-TX400 |Sala Admin |Local Raw Printer |idle |none | |[] | |[] | |[] | |[] |1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/rss+xml, application/vnd.adobe-reader-postscript, application/vnd.cups-banner, application/vnd.cups-command, application|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | | | | | | | | | | |/vnd.cups-pdf, application/vnd.cups-pdf-banner, application/vnd.cups-postscript, application/vnd.cups-ppd, application/vnd.cups-raster, application/vnd.cups-raw, application/x-cshell, application/x-cs| | | |
| | | | | | | | | | | | | | | | |ource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/pwg-raster, image/tiff, image/urf, image/x-alias, image/x-bitmap, image/x-icon, image/x-photocd, image/x-portabl| | | |
| | | | | | | | | | | | | | | | |e-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/x-xwindowdump, text/css, text/html, t| | | |
| | | | | | | | | | | | | | | | |ext/plain] | | | |
|BrGenML1 |BrGenML1 | |Brother BrGenML1 for CUPS |idle |none |iso_a4_210x297mm |[na_letter_8.5x11in, na_legal_8.5x14in, na_executive_7.25x10.5in, na_foolscap_8.5x13in, iso_a4_210x297mm, iso_a5_148x210mm, iso_a6_105x148mm, na_number-10_4.125x9.5in, na_monarch_3.875x7.5in, iso_dl_1|600,600,3 |[300,300,3, 600,600,3, 600,300,3, 2400,600,3, 1200,1200,3] |monochrome |[monochrome] |one-sided |[one-sided, two-sided-long-edge, two-sided-short-edge]|1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/vnd.adobe-reader-postscript, application/vnd.cups-command, application/vnd.cups-pdf, application/vnd.cups-pdf-banner, ap|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | |10x220mm, iso_c5_162x229mm, iso_b5_176x250mm, jis_b5_182x257mm, iso_b6_125x176mm, jis_b6_128x182mm, na_index-4x6_4x6in, jpn_hagaki_100x148mm, jpn_oufuku_148x200mm, jpn_you4_105x235mm, custom_195.09x26| | | | | | | | |plication/vnd.cups-postscript, application/vnd.cups-raw, application/x-cshell, application/x-csource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/tiff, image/x-bit| | | |
| | | | | | | |9.88mm_195.09x269.88mm, custom_184.15x260mm_184.15x260mm, om_197x273mm_197x273mm, custom_min_3x5in, custom_max_8.5x14in] | | | | | | | | |map, image/x-photocd, image/x-portable-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/| | | |
| | | | | | | | | | | | | | | | |x-xwindowdump, text/css, text/html, text/plain] | | | |
|BROTHER_BN |Printer B/N (Brother MFC7860DW) |Sala admin |Brother MFC7860DW for CUPS |idle |opc-life-over-warning|iso_a4_210x297mm |[na_letter_8.5x11in, na_legal_8.5x14in, na_executive_7.25x10.5in, iso_a4_210x297mm, iso_a5_148x210mm, iso_a6_105x148mm, na_number-10_4.125x9.5in, na_monarch_3.875x7.5in, iso_dl_110x220mm, iso_c5_162x2|600,600,3 |[600,600,3, 2400,600,3] |monochrome |[monochrome] |one-sided |[one-sided, two-sided-long-edge, two-sided-short-edge]|1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/vnd.adobe-reader-postscript, application/vnd.cups-command, application/vnd.cups-pdf, application/vnd.cups-pdf-banner, ap|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | |29mm, om_env-isob5_176.04x250.12mm, om_env-isob6_124.88x176.04mm] | | | | | | | | |plication/vnd.cups-postscript, application/vnd.cups-raw, application/x-cshell, application/x-csource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/tiff, image/x-bit| | | |
| | | | | | | | | | | | | | | | |map, image/x-photocd, image/x-portable-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/| | | |
| | | | | | | | | | | | | | | | |x-xwindowdump, text/css, text/html, text/plain] | | | |
|Brother_DCP-L8410CDW|Brother_DCP-L8410CDW |Sala Admin 2 |Brother DCP-L8410CDW CUPS |idle |none |iso_a4_210x297mm |[iso_a4_210x297mm, na_letter_8.5x11in, na_legal_8.5x14in, na_executive_7.25x10.5in, iso_a5_148x210mm, om_a5-rotated_209.9x148.17mm, iso_a6_105x148mm, jis_b5_182x257mm, om_jisb5_182.03x257.18mm, om_jis|600,600,3 |[600,600,3] |color |[monochrome, color]|one-sided |[one-sided, two-sided-long-edge, two-sided-short-edge]|1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/vnd.adobe-reader-postscript, application/vnd.cups-command, application/vnd.cups-pdf, application/vnd.cups-pdf-banner, ap|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | |b6_128.06x182.03mm, iso_dl_110x220mm, iso_c5_162x229mm, na_number-10_4.125x9.5in, na_monarch_3.875x7.5in, oe_br3x5_3x5in, na_foolscap_8.5x13in, jpn_hagaki_100x148mm, jpn_you4_105x235mm, jpn_chou3_120x| | | | | | | | |plication/vnd.cups-postscript, application/vnd.cups-raw, application/x-cshell, application/x-csource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/tiff, image/x-bit| | | |
| | | | | | | |235mm, custom_209.9x269.88mm_209.9x269.88mm, custom_195.09x269.88mm_195.09x269.88mm, om_mexican-legal_215.9x339.73mm] | | | | | | | | |map, image/x-photocd, image/x-portable-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/| | | |
| | | | | | | | | | | | | | | | |x-xwindowdump, text/css, text/html, text/plain] | | | |
|Brother_MFC7860DW |Brother_MFC7860DW |Sala Admin 1 |Brother MFC7860DW for CUPS |stopped|opc-life-over-warning|iso_a4_210x297mm |[na_letter_8.5x11in, na_legal_8.5x14in, na_executive_7.25x10.5in, iso_a4_210x297mm, iso_a5_148x210mm, iso_a6_105x148mm, na_number-10_4.125x9.5in, na_monarch_3.875x7.5in, iso_dl_110x220mm, iso_c5_162x2|2400,600,3 |[600,600,3, 2400,600,3] |monochrome |[monochrome] |one-sided |[one-sided, two-sided-long-edge, two-sided-short-edge]|1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/vnd.adobe-reader-postscript, application/vnd.cups-command, application/vnd.cups-pdf, application/vnd.cups-pdf-banner, ap|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | |29mm, om_env-isob5_176.04x250.12mm, om_env-isob6_124.88x176.04mm] | | | | | | | | |plication/vnd.cups-postscript, application/vnd.cups-raw, application/x-cshell, application/x-csource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/tiff, image/x-bit| | | |
| | | | | | | | | | | | | | | | |map, image/x-photocd, image/x-portable-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/| | | |
| | | | | | | | | | | | | | | | |x-xwindowdump, text/css, text/html, text/plain] | | | |
|CITIZEN_CL-S400DTZ |CITIZEN CL-S400DTZ | |Local Raw Printer |idle |none | |[] | |[] | |[] | |[] |1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/rss+xml, application/vnd.adobe-reader-postscript, application/vnd.cups-banner, application/vnd.cups-command, application|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | | | | | | | | | | |/vnd.cups-pdf, application/vnd.cups-pdf-banner, application/vnd.cups-postscript, application/vnd.cups-ppd, application/vnd.cups-raster, application/vnd.cups-raw, application/x-cshell, application/x-cs| | | |
| | | | | | | | | | | | | | | | |ource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/pwg-raster, image/tiff, image/urf, image/x-alias, image/x-bitmap, image/x-icon, image/x-photocd, image/x-portabl| | | |
| | | | | | | | | | | | | | | | |e-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/x-xwindowdump, text/css, text/html, t| | | |
| | | | | | | | | | | | | | | | |ext/plain] | | | |
|Cups-PDF |Cups-PDF | |Generic CUPS-PDF Printer |idle |none |na_letter_8.5x11in |[na_edp_11x14in, na_ledger_11x17in, na_b-plus_12x19.17in, custom_16x20in_16x20in, custom_16x24in_16x24in, om_2-a_1188.86x1682.04mm, om_4-a_1682.04x2380.9mm, na_govt-letter_8x10in, custom_8x12in_8x12in|300,300,3 |[150,150,3, 300,300,3, 600,600,3, 1200,1200,3, 2400,2400,3] |color |[monochrome, color]|one-sided |[one-sided] |1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/vnd.adobe-reader-postscript, application/vnd.cups-command, application/vnd.cups-pdf, application/vnd.cups-pdf-banner, ap|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | |, iso_a0_841x1189mm, iso_a1_594x841mm, iso_a2_420x594mm, iso_a3_297x420mm, iso_a4_210x297mm, iso_a5_148x210mm, na_letter_8.5x11in, na_c_17x22in, na_d_22x34in, na_e_34x44in, oe_arch-a_9x12in, oe_arch-b| | | | | | | | |plication/vnd.cups-postscript, application/vnd.cups-raw, application/x-cshell, application/x-csource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/tiff, image/x-bit| | | |
| | | | | | | |_12x18in, oe_arch-c_18x24in, oe_arch-d_24x36in, oe_arch-e_36x48in, om_c0_916.87x1296.81mm, om_c1_647.7x916.87mm, om_c2_457.91x647.7mm, om_c3_323.85x457.91mm, om_c4_228.95x323.85mm, iso_c5_162x229mm, n| | | | | | | | |map, image/x-photocd, image/x-portable-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/| | | |
| | | | | | | |a_number-10_4.125x9.5in, iso_dl_110x220mm, na_monarch_3.875x7.5in, na_executive_7.25x10.5in, iso_b0_1000x1414mm, iso_b1_707x1000mm, iso_b2_500x707mm, iso_b3_353x500mm, iso_b4_250x353mm, iso_b5_176x250| | | | | | | | |x-xwindowdump, text/css, text/html, text/plain] | | | |
| | | | | | | |mm, om_jisb0_1029.76x1455.91mm, om_jisb1_727.78x1029.76mm, om_jisb2_514.7x727.78mm, om_jisb3_363.01x514.7mm, om_jisb4_256.47x363.01mm, om_jisb5_182.74x256.47mm, oe_ledger_17x11in, na_legal_8.5x14in, o| | | | | | | | | | | | |
| | | | | | | |m_ra0_859.72x1219.91mm, om_ra1_609.95x859.72mm, om_ra2_429.68x609.95mm, om_ra3_304.8x429.68mm, om_ra4_214.84x304.8mm, om_sra0_899.94x1279.88mm, om_sra1_639.94x899.94mm, om_sra2_449.79x639.94mm, om_sra| | | | | | | | | | | | |
| | | | | | | |3_319.97x449.79mm, om_sra4_224.72x319.97mm, na_super-a_8.94x14in, custom_min_0.5x0.5in, custom_max_35277.78x35277.78mm] | | | | | | | | | | | | |
|EPSON_TMM30 |EPSON TM M30 P1 | |EPSON TM-m30 (rastertotmt) |idle |none |om_rp80x297_71.97x296.97mm |[om_rp80x297_71.97x296.97mm, om_rp58x297_50.8x296.97mm, om_rp80x2000_71.97x2000mm, om_rp58x2000_50.8x2000mm, iso_a4_210x297mm, om_lt_207.89x271.39mm, custom_min_1x1in, custom_max_79.97x2000mm] |203,203,3 |[203,203,3, 182,182,3, 162,162,3, 142,142,3, 121,121,3, 102,102,3, 81,81,3, 77,77,3, 56,56,3]|monochrome |[monochrome] |one-sided |[one-sided] |1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/vnd.adobe-reader-postscript, application/vnd.cups-pdf, application/vnd.cups-pdf-banner, application/vnd.cups-postscript,|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | | | | | | | | | | | application/vnd.cups-raster, application/vnd.cups-raw, application/x-cshell, application/x-csource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/tiff, image/x-bitm| | | |
| | | | | | | | | | | | | | | | |ap, image/x-photocd, image/x-portable-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/x| | | |
| | | | | | | | | | | | | | | | |-xwindowdump, text/css, text/html, text/plain] | | | |
|EpsonTorras |EpsonTorras |EpsonTorras |EPSON TM-m30 (rastertotmt) |idle |none |om_rp80x297_71.97x296.97mm |[om_rp80x297_71.97x296.97mm, om_rp58x297_50.8x296.97mm, om_rp80x2000_71.97x2000mm, om_rp58x2000_50.8x2000mm, iso_a4_210x297mm, om_lt_207.89x271.39mm, custom_min_1x1in, custom_max_79.97x2000mm] |203,203,3 |[203,203,3, 182,182,3, 162,162,3, 142,142,3, 121,121,3, 102,102,3, 81,81,3, 77,77,3, 56,56,3]|monochrome |[monochrome] |one-sided |[one-sided] |1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/vnd.adobe-reader-postscript, application/vnd.cups-pdf, application/vnd.cups-pdf-banner, application/vnd.cups-postscript,|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | | | | | | | | | | | application/vnd.cups-raster, application/vnd.cups-raw, application/x-cshell, application/x-csource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/tiff, image/x-bitm| | | |
| | | | | | | | | | | | | | | | |ap, image/x-photocd, image/x-portable-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/x| | | |
| | | | | | | | | | | | | | | | |-xwindowdump, text/css, text/html, text/plain] | | | |
|EpsonWF4720 |EpsonWF4720 |Sala Admin 1 |Epson WF-4720 Series - epson-inkjet-printer-escpr2 1.1.8-1lsb3.2 (Seiko Epson Corporation LSB 3.2)|idle |none |iso_a4_210x297mm |[iso_a4_210x297mm, om_ta4_209.97x296.93mm, oe_4-x6-full_4x6in, oe_t4-x6-full_4x6in, om_2-l_127x177.97mm, om_t2-l_127x177.97mm, iso_a6_105x148mm, iso_a5_148x210mm, jis_b5_182x257mm, om_l_88.98x127mm, o|300,300,3 |[300,300,3] |color |[monochrome, color]|one-sided |[one-sided, two-sided-long-edge, two-sided-short-edge]|1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/vnd.adobe-reader-postscript, application/vnd.cups-pdf, application/vnd.cups-pdf-banner, application/vnd.cups-postscript,|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | |m_tl_88.98x127mm, oe_index5_5x8in, na_govt-letter_8x10in, oe_t8x10_8x10in, om_4-x7_101.6x180.59mm, om_t4-x7_101.6x180.59mm, jpn_hagaki_100x148mm, om_tpostcard_99.99x148mm, om_env10_104.82x241.3mm, iso| | | | | | | | | application/vnd.cups-raster, application/vnd.cups-raw, application/x-cshell, application/x-csource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/tiff, image/x-bitm| | | |
| | | | | | | |_dl_110x220mm, om_envc6_113.96x161.97mm, na_letter_8.5x11in, oe_tletter_8.5x11in, na_legal_8.5x14in] | | | | | | | | |ap, image/x-photocd, image/x-portable-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/x| | | |
| | | | | | | | | | | | | | | | |-xwindowdump, text/css, text/html, text/plain] | | | |
|MFC7860DW |MFC7860DW | |Brother MFC7860DW for CUPS |idle |none |iso_a4_210x297mm |[na_letter_8.5x11in, na_legal_8.5x14in, na_executive_7.25x10.5in, iso_a4_210x297mm, iso_a5_148x210mm, iso_a6_105x148mm, na_number-10_4.125x9.5in, na_monarch_3.875x7.5in, iso_dl_110x220mm, iso_c5_162x2|600,600,3 |[600,600,3, 2400,600,3] |monochrome |[monochrome] |one-sided |[one-sided, two-sided-long-edge, two-sided-short-edge]|1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/vnd.adobe-reader-postscript, application/vnd.cups-command, application/vnd.cups-pdf, application/vnd.cups-pdf-banner, ap|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | |29mm, om_env-isob5_176.04x250.12mm, om_env-isob6_124.88x176.04mm] | | | | | | | | |plication/vnd.cups-postscript, application/vnd.cups-raw, application/x-cshell, application/x-csource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/tiff, image/x-bit| | | |
| | | | | | | | | | | | | | | | |map, image/x-photocd, image/x-portable-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/| | | |
| | | | | | | | | | | | | | | | |x-xwindowdump, text/css, text/html, text/plain] | | | |
|MunBynBaqueira |MunBynBaqueira |Development Room|POS-80 |idle |none |om_x72-mmy297-mm_71.97x297.04mm|[om_x72-mmy210-mm_71.97x209.9mm, om_x72-mmy297-mm_71.97x297.04mm, om_x72-mmy3276-mm_71.97x3274.48mm] |300,300,3 |[300,300,3] |monochrome |[monochrome] |one-sided |[one-sided] |1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/vnd.adobe-reader-postscript, application/vnd.cups-pdf, application/vnd.cups-pdf-banner, application/vnd.cups-postscript,|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | | | | | | | | | | | application/vnd.cups-raster, application/vnd.cups-raw, application/x-cshell, application/x-csource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/tiff, image/x-bitm| | | |
| | | | | | | | | | | | | | | | |ap, image/x-photocd, image/x-portable-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/x| | | |
| | | | | | | | | | | | | | | | |-xwindowdump, text/css, text/html, text/plain] | | | |
|Zebra-Baqueira-2844 |Zebra-Baqueira-2844 |Deister |Zebra EPL2 Label Printer, 1.3 |idle |none |oe_w198h90_2.75x1.25in |[oe_w90h18_1.25x0.25in, oe_w90h162_1.25x2.25in, oe_w108h18_1.5x0.25in, oe_w108h36_1.5x0.5in, oe_w108h72_1.5x1in, oe_w108h144_1.5x2in, om_w144h26_50.8x9.17mm, oe_w144h36_2x0.5in, oe_w144h72_2x1in, oe_w|203,203,3 |[203,203,3, 300,300,3, 600,600,3] |monochrome |[monochrome] |one-sided |[one-sided] |1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/vnd.adobe-reader-postscript, application/vnd.cups-pdf, application/vnd.cups-pdf-banner, application/vnd.cups-postscript,|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | |144h90_2x1.25in, oe_w144h288_2x4in, oe_w144h396_2x5.5in, oe_w162h36_2.25x0.5in, oe_w162h90_2.25x1.25in, oe_w162h288_2.25x4in, oe_w162h396_2.25x5.5in, om_w171h396_60.33x139.7mm, oe_w180h72_2.5x1in, oe_| | | | | | | | | application/vnd.cups-raster, application/vnd.cups-raw, application/x-cshell, application/x-csource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/tiff, image/x-bitm| | | |
| | | | | | | |w180h144_2.5x2in, oe_w198h90_2.75x1.25in, oe_w216h72_3x1in, oe_w216h90_3x1.25in, oe_w216h144_3x2in, oe_w216h216_3x3in, oe_w216h360_3x5in, oe_w234h144_3.25x2in, oe_w234h360_3.25x5in, oe_w234h396_3.25x5| | | | | | | | |ap, image/x-photocd, image/x-portable-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/x| | | |
| | | | | | | |.5in, om_w234h419_82.55x147.81mm, om_w234h563_82.55x198.61mm, oe_w252h72_3.5x1in, oe_w288h72_4x1in, oe_w288h144_4x2in, oe_w288h180_4x2.5in, oe_w288h216_4x3in, oe_w288h288_4x4in, oe_w288h360_4x5in, oe_| | | | | | | | |-xwindowdump, text/css, text/html, text/plain] | | | |
| | | | | | | |w288h432_4x6in, oe_w288h468_4x6.5in, oe_w288h936_4x13in, custom_min_0.5x0.5in, custom_max_4x50in] | | | | | | | | | | | | |
|Zebra_Printer |Zebra Printer | |Zebra ZPL Label Printer |idle |none |oe_w288h360_4x5in |[oe_w90h18_1.25x0.25in, oe_w90h162_1.25x2.25in, oe_w108h18_1.5x0.25in, oe_w108h36_1.5x0.5in, oe_w108h72_1.5x1in, oe_w108h144_1.5x2in, om_w144h26_50.8x9.17mm, oe_w144h36_2x0.5in, oe_w144h72_2x1in, oe_w|203,203,3 |[203,203,3, 300,300,3, 600,600,3] |monochrome |[monochrome] |one-sided |[one-sided] |1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/vnd.adobe-reader-postscript, application/vnd.cups-pdf, application/vnd.cups-pdf-banner, application/vnd.cups-postscript,|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | |144h90_2x1.25in, oe_w144h288_2x4in, oe_w144h396_2x5.5in, oe_w162h36_2.25x0.5in, oe_w162h90_2.25x1.25in, oe_w162h288_2.25x4in, oe_w162h396_2.25x5.5in, om_w171h396_60.33x139.7mm, oe_w180h72_2.5x1in, oe_| | | | | | | | | application/vnd.cups-raster, application/vnd.cups-raw, application/x-cshell, application/x-csource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/tiff, image/x-bitm| | | |
| | | | | | | |w180h144_2.5x2in, oe_w198h90_2.75x1.25in, oe_w216h72_3x1in, oe_w216h90_3x1.25in, oe_w216h144_3x2in, oe_w216h216_3x3in, oe_w216h360_3x5in, oe_w234h144_3.25x2in, oe_w234h360_3.25x5in, oe_w234h396_3.25x5| | | | | | | | |ap, image/x-photocd, image/x-portable-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/x| | | |
| | | | | | | |.5in, om_w234h419_82.55x147.81mm, om_w234h563_82.55x198.61mm, oe_w252h72_3.5x1in, oe_w288h72_4x1in, oe_w288h144_4x2in, oe_w288h180_4x2.5in, oe_w288h216_4x3in, oe_w288h288_4x4in, oe_w288h360_4x5in, oe_| | | | | | | | |-xwindowdump, text/css, text/html, text/plain] | | | |
| | | | | | | |w288h432_4x6in, oe_w288h468_4x6.5in, oe_w288h936_4x13in, oe_w432h72_6x1in, oe_w432h144_6x2in, oe_w432h216_6x3in, oe_w432h288_6x4in, oe_w432h360_6x5in, oe_w432h432_6x6in, oe_w432h468_6x6.5in, oe_w576h7| | | | | | | | | | | | |
| | | | | | | |2_8x1in, oe_w576h144_8x2in, oe_w576h216_8x3in, oe_w576h288_8x4in, oe_w576h360_8x5in, oe_w576h432_8x6in, oe_w576h468_8x6.5in, custom_min_0.5x0.5in, custom_max_8x50in] | | | | | | | | | | | | |
|Zebra_ZTC_QLn420 |Zebra Technologies ZTC QLn420 (CPCL)| |Local Raw Printer |stopped|paused | |[] | |[] | |[] | |[] |1 |[1, 2, 4, 6, 9, 16]|[application/octet-stream, application/pdf, application/postscript, application/rss+xml, application/vnd.adobe-reader-postscript, application/vnd.cups-banner, application/vnd.cups-command, application|true |[1,9999] |[portrait, landscape, reverse-landscape, reverse-portrait]|
| | | | | | | | | | | | | | | | |/vnd.cups-pdf, application/vnd.cups-pdf-banner, application/vnd.cups-postscript, application/vnd.cups-ppd, application/vnd.cups-raster, application/vnd.cups-raw, application/x-cshell, application/x-cs| | | |
| | | | | | | | | | | | | | | | |ource, application/x-perl, application/x-shell, image/gif, image/jpeg, image/png, image/pwg-raster, image/tiff, image/urf, image/x-alias, image/x-bitmap, image/x-icon, image/x-photocd, image/x-portabl| | | |
| | | | | | | | | | | | | | | | |e-anymap, image/x-portable-bitmap, image/x-portable-graymap, image/x-portable-pixmap, image/x-sgi-rgb, image/x-sun-raster, image/x-xbitmap, image/x-xpixmap, image/x-xwindowdump, text/css, text/html, t| | | |
| | | | | | | | | | | | | | | | |ext/plain] | | | |
+--------------------+------------------------------------+----------------+--------------------------------------------------------------------------------------------------+-------+---------------------+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------+---------------------------------------------------------------------------------------------+----------------+-------------------+------------+------------------------------------------------------+---------------+-------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------+---------------+----------------------------------------------------------+
4 Sending print jobs
Once created a CUPS
client connection object, you can send a text or an stream to one of the printer queues served by this CUPS
server.
You should use the print method which support printing a String or a Stream (file or resource).
4.1 Sending a string
Ax.net.CupsClient object uses method print(String queue, String data) to send a String (text or binary data) to the cups queue.
<script> var cups = new Ax.net.CupsClient('192.168.100.20'); var status = cups.print("BROTHER_BN", "Hello\nworld"); console.log(status); </script>
4.2 Sending a file
Ax.net.CupsClient object uses method print(String queue, Object data) to send an object (file or stream) to the cups queue.
<script> var cups = new Ax.net.CupsClient('192.168.100.20'); var status = cups.print( "BROTHER_BN", new Ax.net.URL('https://bitbucket.org/deister/axional-docs-resources/raw/master/PDF/sample.pdf') ); console.log(status); </script>
Printer-job=946 status=0x0000, description=(successful-ok)
5 Configuring print
When sendind a job to print you can configure the print job.
<script> var cups = new Ax.net.CupsClient('192.168.100.20'); var status = cups.print( "BROTHER_BN", new Ax.net.URL('https://bitbucket.org/deister/axional-docs-resources/raw/master/PDF/sample.pdf'), options => { options.setCopies(1); options.setPageRanges("1"); // pageRanges 1-3, 5, 8, 10-13 options.setUserName("albert"); options.setJobName("Test"); options.setDuplex(false); options.setPortrait(true); options.setColor(false); options.setPageFormat("a4"); // https://www.cups.org/doc/spec-ipp.html options.setAttributes( { "compression":"none", "job-attributes" : "print-quality:enum:3#sheet-collate:keyword:collated#sides:keyword:two-sided-long-edge" } ); } ); console.log(status); </script>
For example, if you want to send to a printer raw data, you can use setAttributes to set document-format to RAW:
<script> var cups = new Ax.net.CupsClient('192.168.100.20'); var attr = {}; attr.document_format = "application/vnd.cups-raw"; var status = cups.print( "BROTHER_BN", new Ax.net.URL('https://bitbucket.org/deister/axional-docs-resources/raw/master/PDF/sample.pdf'), options => { options.setPageRanges("1-1"); options.setAttributes(attr); } ); console.log(status); </script>
6 Printer Queues
You can query print queue of any Printer
<script> var cups = new Ax.net.CupsClient('192.168.100.20'); var rows = []; for (var job of cups.getJobs("BROTHER_BN")) { rows.push([ job.getJobID(), job.getJobName(), job.getUserName(), job.getJobState(), job.getJobURL(), job.getPrinterURL(), job.getSize(), job.getPagesPrinted(), job.getJobCreateTime(), job.getJobCompleteTime() ]); } // Return as a resultset return new Ax.rs.Reader().build(rows, options => { options.setColumnNames([ "JobID", "Job Name", "User Name", "JobState", "Job URL", "Printer URL", "Size", "Pages Printed", "JobCreateTime", "JobCompleteTime" ] ); }); </script>
getJobState() returns current state of a job. According to standard CUPS
implementation, status values can be any of this:
- pending
- pending-held
- processing
- processing-stopped
- canceled
- aborted
- completed
Also, jobs can be cancelled, holded or resumed by using CUPS
Client functions. Next example shows, how to cancel all pending printer jobs:
<script> var cups = new Ax.net.CupsClient('192.168.100.20'); var rows = []; for (var job of cups.getJobs("BROTHER_BN")) { if (job.getJobState() == "pending" || job.getJobState() == "pending-held") { var res = cups.cancelJob(job.getJobID()); if (res) { console.log("Job " + job.getJobID() + " cancelled"); } else { console.log("Cannot cancel Job " + job.getJobID()); } } var ok = cups.holdJob(job.getJobID()); var ok = cups.releaseJob(job.getJobID()); } </script>