Woosim Windows SDK Programmer Reference - Eng v4.3.0
Woosim Windows SDK Programmer Reference - Eng v4.3.0
Version 4.3
October 2020
Woosim Windows SDK Reference
Contents
1. OVERVIEW.............................................................................................................................................. 3
-2-
Woosim Windows SDK Reference
1. Overview
Copyright © 2020 Woosim System Inc.
1.1. Introduction
This Woosim Windows Software Development Kit(SDK) document provides information about
Windows Desktop application development using Woosim printers.
The Library included in the SDK is a DLL file developed based on MFC and runs on Windows Vista or
later versions. The Library API can be referenced in different ways depending on the program
language, and detailed instructions can be found in the example project included in the SDK.
This document was written based on the MFC project code.
The Library and example project were developed in MS Visual Studio 2017 environment.
The example project is based on x86 environment and can be migrated to x64 environment.
Woosim printers are equipped with several types of MCU. The printer's MCU can be checked through
the Self-Test function. If you turn on the printer while pressing the <FEED> button, the Self-Test
function will work.
The SDK supports M16C, ARM, and RX MCU. All APIs are works on RX MCU. There are some APIs that
do not work properly on M16C and ARM MCU.
Most Library APIs create a printer command or a collection of printer commands. To use commands
that are not provided in the Library API, refer to the document “Woosim Command Manual”.
The Printing Data Buffer is a 400KB space in the Library to store data to be transmitted to the printer.
When a Library API creating printer command using the Printing Data Buffer is called, the printer
command is saved in the Printing Data Buffer. The contents stored in the Printing Data Buffer are all
sent to the printer at once when a specific API is called.
-3-
Woosim Windows SDK Reference
Some APIs do not use the Printing Data Buffer and send the printer command to the printer as soon
as it is called. When developing an application program, it is necessary to distinguish between APIs
that use the Printing Data Buffer and APIs that do not use the Printing Data Buffer.
-4-
Woosim Windows SDK Reference
2. API List
2.4.1. General
int ControlCommand(BYTE *data, int length)
void CutPaper(int mode)
void FeedToMark()
void InitLineSpace()
void InitPrinterStatus()
void PrintData()
void PrintDotFeed(int dots)
void PrintLineFeed(int lines)
int PrintSpoolForTTF(char* data, BYTE fontWidth, BYTE fontHeight)
void SetAbsPosition(int distance)
-5-
Woosim Windows SDK Reference
2.4.3. Image
void CompressedAdjustBmpSaveSpool(char *bmpFilePath, int contrast, int brightness)
void CompressedBmpSaveSpool(char *bmpFilePath)
void LoadLogoSaveSpool(int n)
void NormalAdjustBmpSaveSpool(char* bmpFilePath, int contrast, int brightness)
void NormalBmpSaveSpool(char* bmpFilePath)
2.4.4. Barcode
void DataMatrixSaveSpool(int width, int height, int module, char *barcodeData)
void GS1DatabarSaveSpool(int type, int n, char *barcodeData)
void MaxicodeSaveSpool(int mode, char *barcodeData)
void MicroPDF417SaveSpool(int width, int column, int row, int ratio,
char *barcodeData, BOOL bHri)
-6-
Woosim Windows SDK Reference
-7-
Woosim Windows SDK Reference
3. API Reference
baudRate Serial communication speed of the connected printer. You can check it
through the printer Self-Test
Returns
SUCCESS (1) Connection success
ALREADY_OPENED (-1) The printer was connected already
UNABLE_TO_OPEN_THE_PORT (-2) The port is disabled
UNABLE_TO_CONFIGURE_THE_SERIAL_PORT (-3) The port initializing failed
UNABLE_TO_SET_THE_TIMEOUT_PARAMETERS (-4) Time-out setting failed
TIMEOUT (-7) The connection failed within valid time
-8-
Woosim Windows SDK Reference
Returns
SUCCESS (1) Connection success
ALREADY_OPENED (-1) The printer was connected already
SOCKET_ERROR (-2) Socket initialization failed
CONNECT_FAIL (-3) Connection failure
TIMEOUT (-7) The connection failed within valid time
BOOL ClosePrinterConnection()
Terminate the connection with the printer.
Returns
Always TRUE
void EnterMSRMode(int n)
Enter the MSR mode
The magnetic card consists of three tracks, and the tracks can be read differently depending on the
MSR: 12 Track, 23 Track, and 123 Track. The track read depends on the selected mode.
-9-
Woosim Windows SDK Reference
void CancelMSRMode()
Exit the MSR mode.
void EnterSCRMode()
Enter the SCR mode
void CancelSCRMode()
Exit the SCR mode.
void GetPrinterModelName()
Inquire device model name of the connected printer.
The response data from device is firmware dependent. For example, R240(RX)_.
void GetFirmwareVersion()
Inquire device version of the connected printer.
The response data from device is firmware dependent. For example, [Ver 2.0 2018/10/31].
- 10 -
Woosim Windows SDK Reference
The printer status includes condition information by paper sensor, cover sensor, mark sensor and
so on. See the <ESC v> command explanation in the Woosim command manual for details because
the value varies with each printer model.
Parameters
timeoutMsec Maximum time to wait response (msec)
Returns
SUCCESS (1) Success to get printer status
TIMEOUT (-7) The inquiry failed within valid time
NOT_OPEN_THE_PORT (-11) Printer connection error
Returns
SUCCESS (1) Data transfer success
NOT_OPEN_THE_PORT (-11) Printer connection error
void ClearSpool()
Delete the Printing Data Buffer content
int GetSpoolSize()
Get the size of the data stored in the Printing Data Buffer.
Returns
The size of the data stored in the Printing Data Buffer
BYTE* GetSpoolBuffer()
Get the Printing Data Buffer pointer
Returns
The Printing Data Buffer pointer
- 11 -
Woosim Windows SDK Reference
3.4.1. General
Generally used in standard mode, but some also work in page mode. However, there are cases in
which it operates differently in standard mode and page mode.
void InitPrinterStatus()
A command to initialize the printer settings and delete data in the printer buffer is added to the
Printing Data Buffer.
void PrintData()
Add a command to print data in the Standard mode to the Printing Data Buffer. In the Page mode,
it works as a line break.
- 12 -
Woosim Windows SDK Reference
Add a command to set a character code table to the Printing Data Buffer.
The code table that can be selected differs depending on the MCU.
Parameters
n Code table (refer to the below table)
1 Katakana
2 Multilingual CP850
3 Portuguese CP860
4 ISO8859-15 (Latin9)
5 Polish
RX MCU
n Character Code Table
0 USA, Standard Europe [CP437]
1 Katakana
2 Multilingual(Latin-1) [CP850]
3 Portuguese [CP860]
4 Canadian-French [CP863]
5 Nordic [CP865]
6 Slavic(Latin-2) [CP852]
7 Turkish [CP857]
8 Greek [CP737]
9 Russian(Cyrillic) [CP866]
10 Hebrew [CP862]
11 Baltic [CP775]
12 Polish
13 Latin-9 [ISO8859-15]
14 Latin1[Win1252]
15 Multilingual Latin I + Euro[CP858]
16 Russian(Cyrillic)[CP855]
- 13 -
Woosim Windows SDK Reference
17 Russian(Cyrillic)[Win1251]
18 Central Europe[Win1250]
19 Greek[Win1253]
20 Turkish[Win1254]
21 Hebrew[Win1255]
22 Vietnam[Win1258]
23 Baltic[Win1257]
24 Azerbaijani
30 Thai[CP874]
40 Arabic [CP720]
41 Arabic [Win 1256]
42 Arabic (Farsi)
43 Arabic presentation forms B
50 Hindi Devanagari
void SetFontSize(int n)
Add a command to set font size to the Printing Data Buffer.
The font size that can be selected differs depending on the MCU and code table. Refer to the below
table.
n RX M16C, ARM
0 12x24 12x24
1 9x24 9x24
2 8x16 N.A
The Thai font only supports 12x24.
The Arabic and Hindi font only support 16x24.
DBCS fonts only support 24x24.
Parameters
n Font size (0 ~ 2)
void SetTextAlignment(int n)
Add a command to set alignment to the Printing Data Buffer.
Parameters
n The alignment type (Left: 0, Center: 1, Right: 2)
void SetTextStyle(int underline, BOOL bold, int width, int height, BOOL reverse)
Add a command to set character attributes to the Printing Data Buffer.
- 14 -
Woosim Windows SDK Reference
Parameters
underline Underline thickness (0 ~ 2)
void InitLineSpace()
Add a command to initialize line spacing to the Printing Data Buffer.
The initial value is 30 dots.
void SetLineSpace(int n)
Add a command to set line spacing to the Printing Data Buffer.
Parameters
void SetCharSpace(int n)
Add a command to set right-side character spacing to the Printing Data Buffer.
Parameters
Parameters
set If TRUE, following text will print upside-down style
- 15 -
Woosim Windows SDK Reference
Returns
1 on success, 0 on failure
Black mark
Feed direction
distance
Movement Position
- 16 -
Woosim Windows SDK Reference
void FeedToMark()
Add a command to feed paper to the mark sensing position to the Printing Data Buffer.
In practice, feed paper additionally specified by SetPositionFromMark(). It works only when the
printer is set to use the Mark sensor.
width The writing area width in dot unit. It should be bigger than 0
void Page_DrawLine(int x1, int y1, int x2, int y2, int thickness)
Add a command to draw a line to the Printing Data Buffer.
Parameters
- 17 -
Woosim Windows SDK Reference
width
(x, y)
height
radiusW (x, y)
radiusH
- 18 -
Woosim Windows SDK Reference
void Page_Newline()
Add a command to move position to the next line to the Printing Data Buffer.
The new writing position is the left starting point of the next line.
void Page_ClearCurrentData()
Add a command to delete content in the writing area to the Printing Data Buffer.
width The writing area width in dot unit. It should be bigger than 0
void Page_SetDirection(int n)
Add a command to set the printing direction and start position to the Printing Data Buffer.
Parameters
void Page_Print()
Add a command to print content in writing areas to the Printing Data Buffer.
The contents written in the Page mode are not deleted after printing. It can be deleted by
Page_ClearCurrentData().
- 19 -
Woosim Windows SDK Reference
void Page_SetStandardMode()
Add a command to change mode from the Page mode to the Standard mode to the Printing Data
Buffer.
void Page_Print_StandardMode()
Add a command to print content in writing areas and change mode from the Page mode to the
Standard mode to the Printing Data Buffer.
3.4.3. Image
void NormalBmpSaveSpool(char* bmpFilePath)
Add a command to print image file to the Printing Data Buffer.
BMP, JPG, and PNG formats are available.
Parameters
bmpFilePath The file path for printing
contrast Contrast effect adjusted from the original image (-100 ~ 100, default 0)
brightness Brightness effect adjusted from the original image (-255 ~ 255, default 0)
contrast Contrast effect adjusted from the original image (-100 ~ 100, default 0)
brightness Brightness effect adjusted from the original image (-255 ~ 255, default 0)
void LoadLogoSaveSpool(int n)
Add a command to print image that is downloaded in printer to the Printing Data Buffer.
- 20 -
Woosim Windows SDK Reference
The image should be saved in the printer in advance. Refer to the <ESC f> command explanation
in the Woosim Command Mmanual for details.
To save image files to the printer, Woosim Downlaoder program is required. Please contact
Woosim Sales Department.
Parameters
n The index of image stored in printer device.
The maximum count of images that can be stored in device is dependent
on MCU type
3.4.4. Barcode
void OneDimensionBarcodeSaveSpool(BYTE barcodeType, int width, int height, BOOL bHri,
char *barcodeData)
Add a command to print a barcode to the Printing Data Buffer.
Parameters
65 UPC-A 11 ≤ n ≤ 12 48 ≤ d ≤ 57
66 UPC-E 11 ≤ n ≤ 12 48 ≤ d ≤ 57
67 EAN13 11 ≤ n ≤ 13 48 ≤ d ≤ 57
68 EAN8 7≤n≤8 48 ≤ d ≤ 57
48 ≤ d ≤ 57
65 ≤ d ≤ 90
69 CODE39 1 ≤ n ≤ 255
d = 32, 36, 37, 43,
45, 46,47
1 ≤ n ≤ 255
70 ITF 48 ≤ d ≤ 57
(even number)
48 ≤ d ≤ 57
65 ≤ d ≤ 68
71 CODABAR 1 ≤ n ≤ 255
d = 36, 43, 45, 46,
47, 58
72 CODE93 1 ≤ n ≤ 255 0 ≤ d ≤ 127
- 21 -
Woosim Windows SDK Reference
0 ≤ d ≤ 127
d=C1H (FNC1)
73 CODE128 2 ≤ n ≤ 255 d=C2H (FNC2)
d=C3H (FNC3)
d=C4H (FNC4)
void PDF417SaveSpool(int width, int column, int level, int ratio, char *barcodeData,
BOOL bHri)
Add a command to print a PDF417 barcode to the Printing Data Buffer.
Parameters
width The barcode data width (1 ~ 8)
- 22 -
Woosim Windows SDK Reference
22 22 60 24 30 40.0
16 36 34 45 32 42.9 Rectangular
24 24 72 51 36 40.0
26 26 88 63 44 38.9
16 48 98 72 49 36.4 Rectangular
32 32 124 90 62 36.7
36 36 172 126 86 32.8
40 40 228 168 114 29.6
44 44 288 213 144 28.0
48 48 348 258 174 28.1
52 52 408 303 204 29.2
64 64 560 417 280 28.6
72 72 736 549 368 28.1
80 80 912 681 456 29.6
88 88 1152 861 576 28.0
96 96 1392 1041 696 28.1
104 104 1632 1221 816 29.2
120 120 2100 1572 1050 28.0
132 132 2608 1953 1304 27.6
144 144 3116 2334 1558 28.5
* ECC: Error Correction Code rate
- 23 -
Woosim Windows SDK Reference
5 108 86 62 46
6 136 108 76 60
7 156 124 88 66
8 194 154 110 86
9 232 182 132 100
10 274 216 154 122
11 324 254 180 140
12 370 290 206 158
13 428 334 244 180
14 461 365 261 197
15 523 415 295 223
16 589 453 325 253
17 647 507 367 283
18 721 563 397 313
19 795 627 445 341
20 861 669 485 385
21 932 714 512 406
22 1006 782 568 442
23 1094 860 614 464
24 1174 914 664 514
25 1276 1000 718 538
26 1370 1062 754 596
27 1468 1128 808 628
28 1531 1193 871 661
29 1631 1267 911 701
30 1735 1373 985 745
31 1843 1455 1033 793
32 1955 1541 1115 845
33 2071 1631 1171 901
34 2191 1725 1231 961
35 2306 1812 1286 986
36 2434 1914 1354 1054
37 2566 1992 1426 1096
38 2702 2102 1502 1142
39 2812 2216 1582 1222
- 24 -
Woosim Windows SDK Reference
void MicroPDF417SaveSpool(int width, int column, int row, int ratio, char *barcodeData,
BOOL bHri)
Add a command to print a Micro PDF417 barcode to the Printing Data Buffer.
Parameters
width The barcode data width (1 ~ 8)
- 25 -
Woosim Windows SDK Reference
3 38 82 138 202
3 44 97 162 237
4 4 8 14 20
4 6 13 22 32
4 8 20 34 49
4 10 27 46 67
4 12 34 58 85
4 15 45 76 111
4 20 63 106 155
4 26 85 142 208
4 32 106 178 261
4 38 128 214 313
4 44 150 250 366
- 26 -
Woosim Windows SDK Reference
n The segment per row that should be even number in range of 2~20.
Only for the type 6(GS1 Databar Expanded Stacked).
- 27 -
Woosim Windows SDK Reference
4. Sample Projects
The Woosim Windows SDK includes example projects that you can refer to for using the Library.
The example projects were written in Visual C++, Visual C#, and Visual Basic, respectively. The Visual
C++ project was developed based on MFC, and the Visual C# and the Visual Basic projects were
developed based on Windows Forms.
All of the example projects were created with the same UI and include the following features:
- Serial, USB, and Wi-Fi connection
- Text, image, and barcode printing
- Page mode printing
- Magnetic card reading with MSR
The sample project folder also contains executable file. To operate a Woosim printer with the
executable file, you need to check the printer configuration through Self-Test.
The data sent from a printer is received by the Library, and the Library sends a Windows Message to
application programs to notify it. Application programs use RegisterWindowMessage() to receive
the data sent from the printer. At this time, the string defined in the WOOSIM_PRINTER_LIB.h is used
as a parameter.
The UWM_RECEIVE_DATA message is identified by the Windows message loop in the application
program, and the data sent from the printer is received. Please refer to the example project for
details.
Copy the DLL file included in the SDK to the same folder as the executable application program.
4.2. C# Program
Since the WOOSIM_PRINTER_LIB.h file cannot be directly referenced, the Library APIs are referenced
through the DllImport syntax.
- 28 -
Woosim Windows SDK Reference
[DllImport("WoosimPrinter.DLL")]
public static extern bool ClosePrinterConnection();
<DllImport("WoosimPrinter.dll")>
Shared Function ClosePrinterConnection() As Boolean
End Function
- 29 -