Thursday, July 22, 2010

SATO Label Printers Programming Solutions

Background: We were working on the new project on central solution for stores system , I was part of the team responsible for delivering Label Printing solution which gives the central solution across all the stores and as per the Business request we were supposed to develop the application for printing labels for SATO Label printer and we had to write the SPL Sato Programming Language, the drivers for printing label.

Initially we started with ground zero, where there was very little help from the web community and things were not moving as per expected, since we were working in an Agile model, we would be having story points in sprints and it was very difficult to estimate any of the story and couple of sprints went just like that without having any progress, some of our team members also suggested alternative ways to print using win32 API's and drivers, since we were printing on the network printer, installing every printer in all stores is very tedious job and our INFRA team were not ready to take this up. Myself and my lead didnt lose our hope, we kept on trying different approaches there were many challanges in developing this driver, we wanted to print some symbol (Images) barcode , different font size text and at last Koren font printing and one fine day.. slowly things started moving .. we could print some text, inorder to print data into printer first printer needs to be initialized by commands like STX ETX etc and then we need to pass ESCAPE sequence commands in the right order and we have the rotate commands and ESC H ESC V and so on that we slowly stared we could print some text on the labels and we could align after long struggle day and night. We could get little help when we were worried of getting Image print by CodeSoft software where we could get the Image Sequence, we saved all the required image sequence into the text file and then we used to index the images and print the image data from the SPL files. we took around 70 days to complete the label solution. Let me start with Printer Initialize command and Printing Barcode using SPL commands in this first post
Command Structure here it goes :->


Initilize printer : ESC A ESC Z


Define Media Size : A1aaaabbbb


where aaaa = label width in dots (1-832)
bbbb= label length in dots(1-8120)


Set print positions using vertical and horizontal positions:


ESC H aaaa ESC V bbbb
where aaaa and bbbb are defines the position from the origin (0,0) from the starting print position.


Barcode Command :


1:3 narrow/wide bar ratio: Babbcccd
2:5 narrow/wide ratio: BDabbcccd
1:2 narrow/wide bar ratio: Dabbcccd
a =
0 Codabar
1 Code 39
2 Interleaved 2 of 5 (I 2/5)
3 UPC-A / EAN-13
4 EAN-8
5 Industial 2 of 5
6 Matrix 2 of 5
7 reserved
8 reserved
9 reserved
A MSI
B reserved
C Code 93
D reserved
E UPC-E
F Bookland
G Code 128
I UCC 128
bb = Number of dots (01-12) for narrow bar and narrow
space
ccc = Bar height in dots (001-999)
d = UCC 128 only. Not used for other bar code types
0 No human readable text
1 Human readable at top
2 Human readable at bottom

Example for EAN 13 barcode : BD3020800000000000017


Finalize printing Command: ESC Z

Here is the comple escape sequence for printing barcode:



I will post more on text alignment , Unicode language (korean) printing, positioning, Printer settings like speed and darkness and Image printing till then happy programming :)