-
Notifications
You must be signed in to change notification settings - Fork 18
Appendix
This printing option was created in order to use an industrial thermal label printer, the CAB A4+. It communicates over an Ethernet connection, and has an internal FTP server which allows command files to be downloaded into the printer from any workstation in the library.
Briefly, SpineOMatic creates a text file that configures the printer to print each line of the spine label in a specified position, font, and font size. The commands are coded in “Jscript,” a formatting language that is recognized by many CAB (and some other) printers of this type.
To get the printer to print a label, several lines of code must be generated, with one line of code required for each line of the label. These lines are inserted into another block of code that is the same for each label. In the example below, the lines starting with “T” are called “LABELTEXT” in SpineOMatic, and are generated for each label. The lines before and after are unchanged, and are called “Label format commands” in SpineOMatic.
The file that prints the call number “HT 1419 .A5 C318 2011” is shown below.
M 1 fnt;gothic.ttf select internal Century Gothic font
m m dimensions are in millimeters
J Job start
H 100 Heat (Speed) setting (100mm/sec)
S l1;1,0,37,41,25 Size of the Label
O R Orientation Rotated by 180°
T 5,6,0,8,pt12;HT Text “HT” font:#8, 12 pt, 5mm left, 6mm down
T 5,11,0,8,pt12;1419 Text “1419” font:#8, 12 pt, 5mm left, 11mm down
T 5,16,0,8,pt12;.A5 Text “.A5” font:#8, 12 pt, 5mm left, 16mm down
T 5,21,0,8,pt12;C319 Text “C318” font:#8, 12 pt, 5mm left, 21mm down
T 5,26,0,8,pt12;2012 Text “2011” font:#8, 12 pt, 5mm left, 26mm down
A 1 Number of labels to print (1)
For each label, SpineOMatic creates the #LABELTEXT#, and inserts those lines into the Label Format Commands at the point indicated on the configuration screen (below).
This combined block of text is written to a file on the workstation called labelout.txt.
SpineOMatic then shells to the batch file ftpbat.bat, sending IP address of the printer in parameter %1. This file starts an ftp session, using the commands in “sendlabel.txt” and the IP address in %1 to log in to the printer’s FTP server:
@echo OFF
ftp -s:C:\spine\sendlabel.txt %1
The “sendlabel.txt” file contains these commands:
root
1234
put C:\spine\labelout.txt /execute/labelout.txt
quit
where “root” is the login ID of the CAB printer’s FTP server, and 1234 is the password. The file containing the printer commands (labelout.txt) is transferred to the printer’s “execute” directory, which causes the printer to execute the JScript commands and print the label.
For each line of the label to be printed, the #LABELTEXT# is inserted into the Label Format Commands at the point indicated. The combined file is called “labelout.txt.” The count is also inserted into the printer commands. This number is obtained from the label copies value in the user interface.
The batch file ftpbat.bat logs into the printer’s FTP server using the FTP Login values.
The labelout.txt file is then transferred via FTP into the printer’s execute directory, which causes the printer to examine the file and execute the commands that print the label.
The setup options for using this printing method allow changing the IP address, login ID and password, as well as certain parameters of the JScript command file, such as line spacing, margins and the like.
While cumbersome to explain, the process is invisible and quick, and the printer prints the spine label in less than a second.
Batch files in Windows harken back to the days of DOS, and can perform a wide variety of tasks, including creating files, running programs, accessing LPT and COM ports, sending text to printers, and many other functions.
Usually when you scan a barcode number and create a spine label, SpineOMatic sends the label text to a desktop or laser printer. But when you select the “use viados.bat” option, the label text is written to a disk file (“label.txt”), and a batch file that you create (“viados.bat”) is then started. This batch file can process the label text any way you like, including sending it to a legacy printer that may need to be controlled directly through an LPT port, for example, rather than through Windows. To take full advantage of this feature will require a detailed knowledge of batch files.
To use the viados option, click the “use viados” checkbox. An edit window appears that displays the current viados.bat batch file, along with some additional controls that allow you to customize its behavior. (You needn’t use this edit window. You can create a batch file with any text editor, name it “viados.bat,” and save it to SpineOMatic’s installation directory.)
In the example above, a barcode number has been scanned, and the label text appears in the Output Box. Clicking the “Run ‘viados’ batch file” button sends this text to a file called “label.txt” and then starts the batch file that appears in the edit window. You can edit the batch file in the window, and then click “Save file” to write it to SpineOMatic’s installation directory.
The “Load file” button will read in the current “viados.bat” file from the directory and display it in the edit window.
One of the editor’s options lets you ensure that each label sent to the “label.txt” file is the same number of lines long, which may be useful when sending the text to a dot-matrix printer using fixed-length labels. In this example, each label will be padded with blank lines to make the label 10 lines long. To prevent any padding, set this value to 0. Instead of this padding, an ASCII value can be appended to the text. The value “12” causes the printer to eject a page, but any code can be appended.
For dot-matrix printers connected via an LPT port, spacing is not measured in fractions of an inch, but rather by a discrete numbers of spaces. The horizontal position of a pocket label, for example, must be set by either a specific number of columns (10 in this example), or by one or more tabs, if the printer is configured to recognize them and space accordingly.
Batch files can accept parameters, and SpineOMatic lets you send up to two of them. The batch file can access these as %~1 and %~2. (The tilde allows spaces to appear within a parameter. Without the tilde, the batch file uses spaces to delimit the parameters.) You can pass either a string of plain text, such as “Batch processing,” or the value of an XML element, such as <library_name> (“O’Neill”) in the example above.
When the batch file runs, this output is produced:
The “type” batch command types the contents of a file. In this case, the batch file types the contents of the label.txt file. SpineOMatic added three lines to the seven lines of the label text in order to make the total 10 lines, as requested.
This window appears because the “pause” command keeps the process from terminating until a key is pressed, and because “Run hidden” is not checked. Without the “pause,” the window will be visible as a flash on the screen. When “Run hidden” is checked, nothing will appear.
Important note about “Run hidden:” The batch file must not request user input when the “Run hidden” box is checked. If the batch file window is hidden, the user will not be able to provide the required input, and the “cmd.exe” process in Windows will run without terminating. To prevent this from happening, SpineOMatic will not run a batch file in hidden mode if the file contains the “pause” or the “PathName” command. These commands require the user to “Press any key to continue . . .”, or to enter a value, respectively. If you need to use these commands, do not check the “Run hidden” checkbox.