PrintSpirit releases version 2.04 for Web

Recently, PrintSpirit released version 2.04 for web, which is more powerful, more convenient to use, and solves some bugs.

Main new features

1. JS command to select printer

To select a printer before version 2.04, you need to open the console settings through http://127.0.0.1:9011. Version 2.04 provides a new JS API, which allows you to select printers through JS commands. With this function, you can better control the behavior of the application as needed.

SPIRIT.open(opt, function(p) {		
  p.PrintLabel(...)
  p.close();
})

The first parameter of the SPIRIT.open function (hereinafter referred to as the opt parameter) is very important and can be used for various printing configurations. The relevant fields for selecting the printer opt parameter are type and name. These two fields can be combined in various ways, as follows:

type name result
  • | - | Default printer configured using the console ZPL | -   Select an available printer connected to the USB/parallel port/serial port ZPL | LP1/COM1/Printer | selects the printer specified by name, and the type is ZPL, if the name points to a windows printer, an error will be reported WIN/- | Printer | Select the printer specified by name, and the type is WIN

For example: SPIRIT.open({}, ...) Use the default printer SPIRIT.open({type:"ZPL", ...}, ...) Use the first available ZPL printer SPIRIT.open({type:"ZPL", name:"LP1", ...}, ...) Use a ZPL printer connected to parallel port 1 SPIRIT.open({name:"Microsoft Print to PDF", ...}, ...) Use the PDF virtual printer that comes with Windows

2. Optimize batch printing

The 2.04 printing wizard optimizes the continuous batch printing function, provides a more convenient API, and a better process control method.

Send multiple sets of template variables at one time, and print multiple labels with one command. Suitable for continuous printing with a small quantity.

SPIRIT.open({}, function(p) {
  	p.PrintLabel("953745b5-90f3-4852-805d-d11f994d2374", [vars1, vars2])
})

Starting from version 2.04, the second parameter of PrintLabel can be an array, and each element is a template variable for a label. The printing wizard can automatically complete the printing of all labels without JS control.

Through asynchronous callback to control the printing process, the program can be controlled to ensure that the next set of data is sent after printing, which is suitable for mass printing. In the case of large-volume printers, the problem that is likely to occur is that a large amount of data has been sent to the printer at one time. If printing is interrupted due to paper jams, equipment failures, etc., it is difficult to locate the printing position when the failure occurs. Executing breakpoints to continue hitting can easily cause paper waste. Print Wizard 2.04 has been optimized and provides a convenient API to control the printing process through asynchronous callbacks to ensure that the next label data will be sent after the current label is printed. Asynchronous callback can use function callback or async/await. It is recommended to use async/await as much as possible if the browser supports it.

SPIRIT.open({}, async function(p) {
    for(var i=0; i<6; i++) {
       try {
           vars.name="name" + i;
           var rc=await p.PrintLabel("953745b5-90f3-4852-805d-d11f994d2374", vars);
           /* Print complete can be marked here */
       }catch(rc){
           alert(rc.msg);
       }
    }	
    p.close();
})

3. Automatic imposition

Automatic imposition can print multiple labels on a sheet of paper, such as A4 paper can print 3X4 labels of 7cmX7cm. Automatic imposition can save paper and improve printing speed.

The parameters for controlling automatic imposition are controlled by the col and row fields in the open opt. Both col and row have three values: 1. Number. Set the number of rows/columns for imposition. For example: {col:3, row:4} means 3x4 labels are printed on each page. 1. auto. Indicates that the number of rows/columns is automatically calculated. 1. When not set, the default value is 1.

The following program will print 12 labels on two pages (6 per page).

SPIRIT.open({col:2, row:3}, async function(p) {
     for(var i=0; i<12; i++) {
        vars.name="name" + i;
        var rc=await p.PrintLabel("953745b5-90f3-4852-805d-d11f994d2374", vars);
     }
     p.close();
})

The print wizard will automatically calculate the required paper size, if it is not large enough, it will report an error.

4. Double-port start printing service to avoid port being occupied

The print wizard uses 9011 as the print service port. If it is occupied by other software, the print service may not start. In order to solve this problem, version 2.04 uses two service ports (9011, 19011) at the same time, basically no longer being occupied at the same time.

With dual ports, the application only needs to reference spirit.js from both ports at the same time, no other modifications are required.

<script src="http://127.0.0.1:9011/js/spirit.js"></script>
<script src="http://127.0.0.1:19011/js/spirit.js"></script>

Leave Your Message

login