0% found this document useful (0 votes)
132 views37 pages

User Manual

This document provides an overview and reference for an iOS printer SDK. It describes the supported platforms, development environment, and models/interfaces. It also defines constants, commands, and classes for controlling a printer, including printing text, barcodes, images, cutting paper, and more. The RTPrinter command control class is defined, with properties and methods for initializing the printer, setting print options, and printing data.

Uploaded by

Fahmi Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views37 pages

User Manual

This document provides an overview and reference for an iOS printer SDK. It describes the supported platforms, development environment, and models/interfaces. It also defines constants, commands, and classes for controlling a printer, including printing text, barcodes, images, cutting paper, and more. The RTPrinter command control class is defined, with properties and methods for initializing the printer, setting print options, and printing data.

Uploaded by

Fahmi Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 37

C on

te nts
1. About
this
ios Printer SDK guide
..................................................................................................................................................4

API Reference Guide 1-1

V1.0.0

Supported Platforms & Development Environment................................................................4


1-2Models / interface list........................................................................................................ 4
1-3 Xcode static library use..................................................................................................... 4
2. Contant....................................................................................................................................... 7
2-1 Contant definition............................................................................................................. 7
2-1-1 character set.......................................................................................................... 7
2-1-2International character set.....................................................................................8
2-1-3 Chinese encoding format....................................................................................... 9
2-1-4 Barcode / image / text alignment..........................................................................9
2-1-5 Select the print mode............................................................................................ 9
2-1-6 Select HRI character printing position..............................................................9

1
2-1-7 Select and print the bar code system...................................................................10
2-1-8 Set character size................................................................................................. 10
2-1-9 Real-time transmission printer ID........................................................................11
2-1-10 Real-time status transmit................................................................................... 11
2-1-11 Real-time printer request................................................................................... 11
2-1-12 Real-time pulse generator.................................................................................. 11
2-1-13 Select the bitmap mode..................................................................................... 12
2-1-14 Set / release underline mode.............................................................................12
2-1-15 Select the font................................................................................................... 12
2-1-16 Set / release 90 ° clockwise rotation..................................................................12
2-1-17 Set bitmap mode............................................................................................... 12
2-1-18 Select HRI character font...................................................................................13
2-1-19 Set / release inverse print mode........................................................................13
2-1-20 Barcode width.................................................................................................... 13
2-1-21 Select print direction in page mode...................................................................13
2-1-22 Set / release Bold............................................................................................... 14
2-1-23 Select paper cutting mode.................................................................................14
2-1-24 Set/Release invert printing mode.......................................................................14
2-1-25 Port selection..................................................................................................... 14
3.RTPrinter command control class definition (reference)............................................................15
3-1 Overview........................................................................................................................ 15
3-2 Porperties....................................................................................................................... 15
3-2-1 delegate............................................................................................................... 15
3-2-2 - (BOOL) InitPrinter.............................................................................................. 16
3-2-3 - (void) HT............................................................................................................ 16
3-2-4 - (void) LF............................................................................................................. 17
3-2-5 - (void) CR............................................................................................................ 17
3-2-6 - (void) Selftest Print............................................................................................ 18
3-2-7 - (void) SetRightSpace:(Byte)Distance..................................................................18
3-2-8 - (void) SetAbsoluteprintPosition:(Byte)nL highByte:(Byte)nH.............................18
3-2-9 - (void) SetRelativeprintPosition:(Byte)nL highByte:(Byte)nH..............................19
3-2-10 - (void) Set Default Line Spacing........................................................................20
3-2-11 - (void) Set Line Spacing:(Byte)Line Spacing.......................................................20
3-2-12 - (void) Set Left Start Spacing:(Byte)nL highByte:(Byte)nH.................................20
3-2-13 - (void) Set Area Width:(Byte)nL highByte:(Byte)nH..........................................21
3-2-14 - (void) Set Character Printmode:(Byte)Character Print mode...........................21
3-2-15 - (void) Set Underline:(Byte)UnderLine En........................................................22
3-2-16 - (void) Add Bold:(Byte)BoldEn..........................................................................22
3-2-17 - (void) SetCharacterFont:(Byte)Font.................................................................23
3-2-18 - (void) SetRotate:(Byte)RotateEN.....................................................................23
3-2-19 SetAlignMode................................................................................................... 24
3-2-20 - (void) SetInvert Print:(Byte)Invert ModeEn.....................................................24
3-2-21 - (void) Set Zoom:(Byte)Font Enlarge.................................................................25
3-2-22 - (void) Set BlackReverse Print:(Byte)BlackReverse En.......................................26

2
3-2-23 - (void) OpenDrawer:(Byte)DrawerNumber startTime:(Byte)pulseStartTime
endTime:(Byte)PulseEndTime....................................................................................... 26
3-2-24 - (void) Cut Paper.............................................................................................. 27
3-2-25 - (void) partial Cut Paper................................................................................... 27
3-2-26 ① - (void) Feed And Cut Paper:(Byte)Cut Mode.............................................28
②- (void) Feed And Cut Paper:(Byte)Cut Mode feed:(Byte)Feed Distance....................28
3-2-27 Add Bar Code Print............................................................................................ 28
3-2-28 Begin Print Image............................................................................................... 30
3-3 Instance Methods.......................................................................................................... 31
3-3-1 Begin................................................................................................................... 31
3-3-2 Excute.................................................................................................................. 32
3-3-3 Import Data......................................................................................................... 32
3-3-4 Clear Data........................................................................................................... 32
3-3-5 btn Connect........................................................................................................ 33
3-3-6 btnPrint............................................................................................................... 33
3-3-7 btn Preferences Click........................................................................................... 34
4.Agreement Involved.................................................................................................................. 36
4-1 Outline............................................................................................................................ 36
4-2 Instance Methods........................................................................................................... 36
4-2-1 connect Host........................................................................................................ 36
4-2-2 disconnect.......................................................................................................... 37
5.Appendix................................................................................................................................... 37

1. About this guide

This guide describes the SDK library functions for IOS application development.

1-1 Supported Platforms & Development Environment

 Platform
iOS 4.3 or higher

 Development environment
XCode 4.2.6 or higher

3
1-2Models / interface list

Model Ethernet Wifi Bluetooth


RP80 ○ × ×
RP80W × ○ ×
RPP-02 × × ○

1-3 Xcode static library use

1-3-1 Add CFNetwork.framework and static library files libWifiPrinter_SDK.a

1) Select "project file and target" option

2) Select "Build Phasaes" label

3) Select "Link Binary With Libaries" project, click on the "+" pop up boxes as follow, select

CFNetwork.framework and static library files libWifiPrinter_SDK.a added to the project.

4
1-3-2 Add a static library appropriate header files

Add three static library header files to your project.:WifiPrinter.h, WifiPrinterDelegate.h,

AsynSocket.h

5
2. Contant

SDK provides all defined constants used in WifiPrinter.h.

2-1 Contant definition

2-1-1 character set

The following is a list of character set supported , the default character set is RT_CS_CP437.

Code Value Description


RT_CS_CP437 0 CP437【US,European standard】
RT_CS_KATAKANA 1 KataKana【KataKana】
RT_CS_CP850 2 CP850【multilingual】
RT_CS_CP860 3 CP860【Portugal】
RT_CS_CP863 4 CP863【Canada - French】
RT_CS_CP865 5 CP865【Nordic】
RT_CS_WP1251 6 WCP1251【Cyrillic】
RT_CS_CP866 7 CP866【Slavic2】

6
RT_CS_MIK 8 MIK【Slavic / Bulgarian】
RT_CS_CP755 9 CP755【Eastern Europe, Latvia2】
RT_CS_CP862 15 CP862【Hebrew】
RT_CS_WCP1252 16 WCP1252【 Latin1】
RT_CS_WCP1253 17 WCP1253【Greece】
RT_CS_CP852 18 CP852【Latin2】
RT_CS_CP858 19 CP858【Latin characters1+European
languages】
RT_CS_IRANII 20 Iran II【Persian】
RT_CS_LATVIA 21 Latvia
RT_CS_CP864 22 CP864【Arabic】
RT_CS_ISO88591 23 ISO-8859-1【Western Europe】
RT_CS_CP737 24 CP737【Greece】
RT_CS_WCP1257 25 WCP1257【Baltic】
RT_CS_THAI 26 Thai
RT_CS_CP720 27 CP720【Arabic】
RT_CS_CP855 28 CP855
RT_CS_857 29 CP857【Turkish】
RT_CS_WCP1250 30 WCP1250【Central Europe】
RT_CS_CP775 31 CP775
RT_CS_WCP1254 32 WCP1254【Turkish】
RT_CS_WCP1255 33 WCP1255【Hebrew】
RT_CS_WCP1256 34 WCP1256【Arabic】
RT_CS_WCP1258 35 WCP1258【Vietnamese】
RT_CS_ISO88592 36 ISO-8859-2【Latin2】
RT_CS_ISO88593 37 ISO-8859-3【Latin3】
RT_CS_ISO88594 38 ISO-8859-4【Baltic】
RT_CS_ISO88595 39 ISO-8859-5【Cyrillic】
RT_CS_ISO88596 40 ISO-8859-6【Arabic】
RT_CS_ISO88597 41 ISO-8859-7【Greek】
RT_CS_ISO88598 42 ISO-8859-8【Hebrew】
RT_CS_ISO88599 43 ISO-8859-9【Turkish】
RT_CS_ISO885915 44 ISO-8859-15【9Latin 9】
RT_CS_THAI2 45 【Thai 2】
RT_CS_CP856 46 CP856
RT_CS_CP874 47 CP874

2-1-2International character set

The following is a list of supported international character set, the default character set is
RT_ICS_CHINESE

7
Code Value Description
RT_ICS_USA 0 United States
RT_ICS_FRANCE 1 France
RT_ICS_GERMANY 2 Germany
RT_ICS_ENGLAND 3 British
RT_ICS_DENMARKI 4 Denmark I
RT_ICS_SWEDEN 5 Sweden
RT_ICS_ITALY 6 Italy
RT_ICS_SPAINI 7 Spanish I
RT_ICS_JAPAN 8 Japan
RT_ICS_NORWAY 9 Norway
RT_ICS_DENMARKII 10 Denmark II
RT_ICS_SPAINII 11 Spain II
RT_ICS_LATIN 12 Latin America
RT_ICS_KOREAN 13 Korea
RT_ICS_SLOVENIA 14 Slovenia
RT_ICS_CHINA 15 China

2-1-3 Chinese encoding format

Code Value Description


RT_ENCODING_GBK 0 GBK encoding
RT_ENCODING_UTF_8 1 UTF-8 encoding
RT_ENCODING_BIG5 3 BIG5 traditional Chinese encoding

2-1-4 Barcode / image / text alignment

Code Value Description


RT_ALIGNMENT_LEFT 0 Align Left
RT_ALIGNMENT_CENTER 1 Align Center
RT_ALIGNMENT_RIGHT 2 Align Right

8
2-1-5 Select the print mode

Code Value Description


RT_FT_DEFAULT 0x00 default value
RT_FT_FONTA 0x00 Character font A(12*24)
RT_FT_FONTB 0x01 Character font B(9*17)
RT_FT_BOLD 0x08 Set bold mode
RT_FT_DHEIGHT 0x10 Set times the height mode
RT_FT_DWIDTH 0x20 Set times the height width mode
RT_FT_UNDERLINE 0x80 Set underline mode

2-1-6 Select HRI character printing position

Code Value Description


RT_HRI_NONE 0 Do not print HRI character
RT_HRI_ABOVE 1 Above the barcode
RT_HRI_BELOW 2 below the barcode
RT_HRI_BOTH 3 Above and below the barcode

2-1-7 Select and print the bar code system

Code Value Number of Data Range of Data


RT_BCS_UPCA 0x65 11<=n <=12 48<=d<=57
RT_BCS_UPCE 0x66 11<=n<=12 48<=d<=57
RT_BCS_EAN13 0x67 12<=n<=13 48<=d<=57
RT_BCS_EAN8 0x68 7<=n<=8 48<=d<=57
RT_BCS_CODE39 0x69 1<=n<=255 48<=d<=57,65<=d<=90,32,36,37,43,45,46,4
7
RT_BCS_ITF 0x70 1<=n<=255(even 48<=d<=57
number)
RT_BCS_CODABAR 0x71 1<=n<=255 48<=d<=57,65<=d<=68,36,43,45,46,47,58
RT_BCS_CODE93 0x72 1<=n<=255 0<=d<=127
RT_BCS_CODE128 0x73 2<=n<=255 0<=d<=127

2-1-8 Set character size

 Character width setting


Code Value Description

9
RT_TS_1WIDTH 0x00 1(general)
RT_TS_2WIDTH 0x10 2 times the width
RT_TS_3WIDTH 0x20 3 times the width
RT_TS_4WIDTH 0x30 4 times the width
RT_TS_5WIDTH 0x40 5 times the width
RT_TS_6WIDTH 0x50 6 times the width
RT_TS_7WIDTH 0x60 7 times the width
RT_TS_8WIDTH 0x70 8 times the width
 Character height settings
Code Value Description
RT_TS_1HEIGHT 0x00 1(general)
RT_TS_2HEIGHT 0x01 2 times the height
RT_TS_3HEIGHT 0x02 3times the height
RT_TS_4HEIGHT 0x03 4times the height
RT_TS_5HEIGHT 0x04 5times the height
RT_TS_6HEIGHT 0x05 6times the height
RT_TS_7HEIGHT 0x06 7times the height
RT_TS_8HEIGHT 0x07 8times the height

2-1-9 Real-time transmission printer ID

Code Value Description


RT_ID_MODLE 49 Printer ID Model
RT_ID_NUMBER 50 ID Model
RT_ID_VERSION 65 Hardware version
RT_ID_FIRM 66 Company
RT_ID_PRINTERNAME 67 Printer Name
RT_ID_UARTNAME 68 Serial name
RT_ID_ENCODINGTYPE 69 Multi-byte character

2-1-10 Real-time status transmit

Code Value Description


RT_STATE_PRINTER 1 Printer Status
RT_STATE_OFFLINE 2 Offline Status
RT_STATE_ERR 3 Error Status
RT_STATE_SENSOR 4 Continuous paper sensor status

10
2-1-11 Real-time printer request

Code Value Description


RT_REQ_LINE 1 Recover from the error and resume printing from the
error line
RT_REQ_CLEAR 2 Recover from the error after clearing the receive and
print buffers

2-1-12 Real-time pulse generator

Code Value Description


RT_CASHDRAWER_PIN_2 0 Cash drawer connect pin 2
RT_CASHDRAWER_PIN_5 1 Cash drawer connect pin 5

2-1-13 Select the bitmap mode

Code Value Description


RT_DENSITY_SINGLE_8 0 8 - point single density
RT_DENSITY_DOUBLE_8 1 8 - point double density
RT_DENSITY_SINGLE_24 32 24 - Point single density
RT_DENSITY_DOUBLE_24 33 24 - Point Dual Density

2-1-14 Set / release underline mode

Code Value Description


RT_UNDERLINE_DIS 0 Release underline mode
RT_UNDERLINE_1 1 Set underline mode (1 point coarse)
RT_UNDERLINE_2 2 Set underline mode (2 point coarse)

2-1-15 Select the font

Code Value Descr


RT_FONT_A 0 Select font A(12*24)
RT_FONT_B 1 Select font B(9*17)

11
2-1-16 Set / release 90 ° clockwise rotation

Code Value Description


RT_CLOCKWISE_DIS 0 Release 90 ° clockwise rotation mode
RT_CLOCKWISE_EN 1 Set 90 ° clockwise rotation mode

2-1-17 Set bitmap mode

Code Value Description


RT_BMP_NORMAL 0 Normal (vertical 203.2dpi, level 203.2dpi)
RT_BMP_DOUBLEWIDTH 1 Times the width(vertical 203.2dpi, level
101.6dpi))
RT_BMP_DOUBLEHEIGHT 2 Times the height(vertical 101.6dpi, level
203.2dpi)
RT_BMP_FOURTHTIMES 3 4 times the size(vertical 101.6dpi, level
101.6dpi)

2-1-18 Select HRI character font

Code Value Description


RT_HRI_FONTA 0 Font A(12*24)
RT_HRI_FONTB 1 Font B(9*17)

2-1-19 Set / release inverse print mode

Code Value Description


RT_INVERSE_DIS 0x00 Inverse mode off
RT_INVERSE_EN 0x01 Inverse mode on

2-1-20 Barcode width

Code Value Description


Multi-stage bar Binary barcode(mm)
code(mm) Strips Broad
RT_BARCODE_1 2 0.250 0.250 0.625
RT_BARCODE_2 3 0.375 0.375 1.000
RT_BARCODE_3 4 0.560 0.500 1.250
RT_BARCODE_4 5 0.625 0.625 1.625

12
RT_BARCODE_5 6 0.750 0.750 2.000

2-1-21 Select print direction in page mode

Code Value Description


RT_DIRECTION_LEFT_RIGHT 0 Print from left to right
RT_DIRECTION_BOTTOM_TOP 1 Print from the bottom to top
RT_DIRECTION_RIGHT_LEFT 2 Print from right to left
RT_DIRECTION_TOP_BOTTOM 3 Print from the top to bottom

2-1-22 Set / release Bold

Code Value Description


RT_BOLD_DIS 0x00 Release Bold print mode
RT_BOLD_EN 0x01 Set bold print mode

2-1-23 Select paper cutting mode

Code Value Description


RT_CUT_PARTIAL 0x31 partial cutting(have a less bit retained)
RT_CUT_WITHFEED 0x42 Feed paper(cutting position + [n
×0.125mm]),
And partial cutting(have a less bit
retained)

2-1-24 Set/Release invert printing mode

Code Value Description


RT_INVERT_DIS 0 Release invert printing
RT_INVERT_EN 1 set invert printing

13
2-1-25 Port selection

Code Value Description


RT_CONNECTION_WIFI 0x0000 Wi-Fi
RT_CONNECTION_ETHERNET 0x0001 Ethernet
RT_CONNECTION_BLUETOOTH 0x0002 Bluetooth

3.RTPrinter command control class definition

(reference)

Inherits from NSObject


Confirms to
Framework libWifiPrinter_SDK.a
CFNetwork.framework
[Availability] iOS 4.3 or higher
Declared WifiPrinter.h

3-1 Overview

This section mainly describes our Company's printer control method class definition.

14
3-2 Porperties

3-2-1 delegate

@property (readwrite) id<initWithDelegate> de

【Description】
This part is for the control function initialization
【Applicable version】
SDK 1.0.0 or higher
【Example】
@interface delegateTestClass : NSObject

{ //Declaration
}
@end
@implementation TestClass
//process
-(id) initWithDelegate : (id) de

{ //Implementation
self = [super init];
if(self){
delegate = de;
if(mCmdBuffer == NULL)
mCmdBuffer = malloc(sizeof(Byte)*BUFFER_MAX_LEN);
mIndex = 0;
}
return self;
}

3-2-2 - (BOOL) InitPrinter

【Description】
This part is for the printer initialization

15
【Applicable version】
SDK 1.0.0 or higher
【Example】
Byte combyte[] = {0x1B, 0x40};

if(![asyncSocket isConnected])
retrurn false;

NSData *data = [[NSData alloc] initWithBytes : combyte length : 2];


[self SendData : data];

return true;

3-2-3 - (void) HT

【Description】
Moves the print position to the next level anchor position (horizontal orientation)
HT

【Applicable version】
SDK 1.0.0 or higher

【Example】
mCmdBuffer[mIndex++] = 0x09;

3-2-4 - (void) LF

【Description】
Print the data form the butter area,and forward the the paper one line in accordance with
the current line spacing
LF
【Note】
This command sets the print position to the beginning of the line
【Applicable version】
SDK 1.0.0 or higher
【Example】
mCmdBuffer[mIndex++] = 0x0A;

16
3-2-5 - (void) CR

【Description】
Print and carriage returnCR
CR
【Note】
 This command function is the same as LF’s function when allowing automatic
document feed.
 The command is ignored when not allow automatic document feed.
 For serial interface mode, the command’s line paper feed function is ignored.
 Set the printing start position to the starting point of the line.

【Applicable version】
SDK 1.0.0 or higher

【Example】
mCmdBuffer[mIndex++] = 0x0D;

3-2-6 - (void) Selftest Print

【Description】
Print test test page
【Applicable version】
SDK 1.0.0 or higher

【Example】
mCmdBuffer[mIndex++] = 0x12;
mCmdBuffer[mIndex++] = 0x54;

3-2-7 - (void) SetRightSpace:(Byte)Distance

@property (readwrite) Byte Distance


【Description】
Set Character right interval as [Distance *0.125 mm]
【Note】
 For Times the width mode, character right interval is twice wider than normal mode. If
font size is enlarged, character right space is n times wider than normal model.
 The demand does not influence the set of Chinese character.

17
 Set value standard mode independently in every mode.
【Applicable version】
SDK 1.0.0 or higher

【Example】
mCmdBuffer[mIndex++] = 0x1B;
mCmdBuffer[mIndex++] = 0x20;
mCmdBuffer[mIndex++] = Distance;

3-2-8 - (void) SetAbsoluteprintPosition:(Byte)nL highByte:(Byte)nH

@property(readwrite) Byte nL
@property(readwrite) Byte nH

【Description】
This command sets the print position to the beginning of the line.
The space from the print position to the beginning of the line is [(nL + nH *256)*0.125 mm].

【Note】
 The set outside the specified print range is ignored.
 Use the horizontal motion units in standard mode.

【Applicable version】
SDK 1.0.0 or higher

【Example】
mCmdBuffer[mIndex++] = 0x1B;
mCmdBuffer[mIndex++] = 0x24;
mCmdBuffer[mIndex++] = nL;
mCmdBuffer[mIndex++] = nH;

3-2-9 - (void) SetRelativeprintPosition:(Byte)nL highByte:(Byte)nH

@property(readwrite) Byte nL
@property(readwrite) Byte nH
【Description】
Take the current position as basis point, use horizontal or vertical motion units, set the
beginning& ending print position.
The command set the print position from the current position to [(nL + nH *256)*0.125 mm].

【Note】

18
 Any set is ignored if outside the specified print range.
 If the space N is appointed to right : nL+ nH*256 = N
If N is appointed to left: (reverse), use the complement of 65536. nL+ nH*256 = 65536
– N.

【Applicable version】
SDK 1.0.0 or higher

【Example】
mCmdBuffer[mIndex++] = 0x1B;
mCmdBuffer[mIndex++] = 0x5C;
mCmdBuffer[mIndex++] = nL;
mCmdBuffer[mIndex++] = nH;

3-2-10 - (void) Set Default Line Spacing

【Description】
Linespacing is selected to be 3.75 mm(30*0.125mm).

【Applicable version】
SDK 1.0.0 or higher.

【Example】
mCmdBuffer[mIndex++] = 0x1B;
mCmdBuffer[mIndex++] = 0x32;

3-2-11 - (void) Set Line Spacing:(Byte)Line Spacing

@property (readwrite) Byte Line Spacing

【Description】
This part is to set line spacing, as param * 0.125mm.
ESC 3 n

【Note】
 Line spacing can be set independently in standard mode and page mode.
 Use vertical motion units in standard mode(y).

【Applicable version】
SDK 1.0.0 or higher.

19
【Example】
mCmd Buffer[mIndex++] = 0x1B
mCmd Buffer[mIndex++] = 0x33;
mCmd Buffer[mIndex++]= Set Line Spacing;

3-2-12 - (void) Set Left Start Spacing:(Byte)nL highByte:(Byte)nH

@property(readwrite) Byte nL
@property(readwrite) Byte nH

【Description】
Left blank is set as[(nL + nH *256)*0.125 mm].

【Applicable version】
SDK 1.0.0 or higher.

【Example】
mCmd Buffer[mIndex++] = 0x1D;
mCmd Buffer[mIndex++] = 0x4C;
mCmd Buffer[mIndex++] = nL;
mCmd Buffer[mIndex++] = nH;

3-2-13 - (void) Set Area Width:(Byte)nL highByte:(Byte)nH

@property(readwrite) Byte nL
@property(readwrite) Byte nH

【Description】
The width of print range is set as [(nL + nH *256)*0.125 mm].

【Applicable version】
SDK 1.0.0 or higher.

【Example】
mCmd Buffer[mIndex++] = 0x1D;
mCmd Buffer[mIndex++] = 0x57;
mCmd Buffer[mIndex++] = nL;
mCmd Buffer[mIndex++] = nH;

20
3-2-14 - (void) Set Character Printmode:(Byte)Character Print
mode

@property(readwrite) Byte Character Print mode


【Description】
Select print mode by the specified parameter “Character Print mode”. The parameter n is
defined as follows:
#define RT_FT_DEFAULT 0x00
#define RT_FT_FONTA 0x00
#define RT_FT_FONTB 0x01
#define RT_FT_BOLD 0x08
#define RT_FT_DHEIGHT 0x10
#define RT_FT_DWIDTH 0x20
#define RT_FT_UNDERLINE 0x80

【Applicable version】
SDK 1.0.0 or higher.
【Example】
mCmd Buffer[mIndex++] = 0x1D;
mCmd Buffer[mIndex++] = 0x21;
mCmd Buffer[mIndex++] = RT_FT_DHEIGHT;

3-2-15 - (void) Set Underline:(Byte)UnderLine En

@property(readwrite)Byte UnderLineEn

【Description】
Parameter “UnderLineEn” determines underline parameter, which is defined as follows:
#define RT_UNDERLINE_DIS 0
#define RT_UNDERLINE_1 1
#define RT_UNDERLINE_2 2

【Applicable version】
SDK 1.0.0 or higher.

【Example】
mCmd Buffer[mIndex++] = 0x1B;

21
mCmd Buffer[mIndex++] = 0x2D;
// Set underline mode thickness is 2 point
mCmd Buffer[mIndex++] = RT_UNDERLINE_1;

3-2-16 - (void) Add Bold:(Byte)BoldEn

@property(readwrite)Byte BoldEn

【Description】
This section is used to set / release bold print.
Parameter BoldEn is defined as follows:
#define RT_BOLD_DIS 0x00
#define RT_BOLD_EN 0x01

【Applicable version】
SDK 1.0.0 or higher.

【Example】
mCmdBuffer[mIndex++] = 0x1B;
mCmdBuffer[mIndex++] = 0x45;
// Set the bold print
mCmdBuffer[mIndex++] = RT_BOLD_EN;

3-2-17 - (void) SetCharacterFont:(Byte)Font

@property(readwrite)Byte Font

【Description】
This section is used to select the character for font A or B.
Parameter Font is defined as follows:
#define RT_FONT_A 0x00
#define RT_FONT_B 0x01

【Applicable version】
SDK 1.0.0 or higher.

【Example】
mCmdBuffer[mIndex++] = 0x1B;
mCmdBuffer[mIndex++] = 0x4D;

22
// Font B(9x17)
mCmdBuffer[mIndex++] = RT_FONT_B;

3-2-18 - (void) SetRotate:(Byte)RotateEN

@property(readwrite)Byte RotateEN

【Description】
Set/release 90 ° clockwise rotation.
Parameter RotateEN is defined as follows:
#define RT_CLOCKWISE_DIS 0
#define RT_CLOCKWISE_EN 1
【Applicable version】
SDK 1.0.0 or higher.

【Example】
mCmd Buffer[mIndex++] = 0x1B;
mCmd Buffer[mIndex++] = 0x56;
// Set the 90 ° clockwise rotation mode
mCmd Buffer[mIndex++] = RT_CLOCKWISE_EN;

3-2-19 SetAlignMode

@property(readwrite)Byte AlignMode

【Description】
This part is for selecting alignment.
Parameter AlignMode is defined as follows:
#define RT_ALIGNMENT_LEFT 0
#define RT_ALIGNMENT_CENTER 1
#define RT_ALIGNMENT_RIGHT 2

【Applicable version】
SDK 1.0.0 or higher.

【Example】
mCmdBuffer[mIndex++] = 0x1B;
mCmdBuffer[mIndex++] = 0x61;
//Align Left

23
mCmdBuffer[mIndex++] = RT_ALIGNMENT_LEFT;

3-2-20 - (void) SetInvert Print:(Byte)Invert ModeEn

@property(readwrite)Byte InvertModeEn

【Description】
This section is mainly used to set / release reverse print mode. 
When the lowest valid position of n is 0, reverse print mode turn off.
When the lowest valid position of n is 1, reverse print mode turn on.
Parameter InvertModeEn is defined as follows:
#define RT_INVERT_DIS 0
#define RT_INVERT_EN 1
【Applicable version】
SDK 1.0.0 or higher.

【Example】
mCmdBuffer[mIndex++] = 0x1B;
mCmdBuffer[mIndex++] = 0x7b;
mCmdBuffer[mIndex++] = RT_INVERT_EN;

3-2-21 - (void) Set Zoom:(Byte)Font Enlarge

@property(readwrite) Byte FontEnlarge


【Description】
This section is used to set the character size.
GS ! n

【Note】
 The command set with 0-3 character height, 4-7 to set the character width.
 The command is valid for all the characters(alphanumeric characters and Chinese
characters)except HRI characters.
 When the characters in different sizes amplify in a row, all the characters in a row along
the baseline align.
 In standard mode, the vertical direction is the paper feed direction. However, when the
characters rotate 90 ° clockwise, the relationship between the vertical and the
horizontal direction is reversed.
【Applicable version】
SDK 1.0.0 or higher.

24
【Example】
mCmd Buffer[mIndex++] = 0x1D;
mCmd Buffer[mIndex++] = 0x21;
mCmd Buffer[mIndex++] = FontEnlarge;

3-2-22 - (void) Set BlackReverse Print:(Byte)BlackReverse En

@property(readwrite) Byte BlackReverseEn

【Description】
The section is used to set/release black reverse print mode.
Parameter InvertModeEn is defined as follows:
#define RT_INVERSE_DIS 0x00
#define RT_INVERSE_EN 0x01

【Applicable version】
SDK 1.0.0 or higher.

【Example】
mCmdBuffer[mIndex++] = 0x1D;
mCmdBuffer[mIndex++] = 0x42;
// Set Black Reverse Print Mode
mCmdBuffer[mIndex++] = RT_INVERSE_EN;
// Release Black Reverse Print Mode
mCmdBuffer[mIndex++] = RT_INVERSE_DIS;

3-2-23 - (void) OpenDrawer:(Byte)DrawerNumber startTime:


(Byte)pulseStartTime endTime:(Byte)PulseEndTime

@property(readwrite) Byte DrawerNumber


@property(readwrite) Byte pulseStartTime
@property(readwrite) Byte PulseEndTime

【Description】
DrawerNumber = 0, 1, 48, 49
0 <= pulseStartTime <= 255
0 <= PulseEndTime <= 255

【Description】

25
Send an impulse to specified connected pins.
On time= pulseStartTime x 2 millisecond
Off time= PulseEndTime x 2 millisecond
m =0/48 Impulse sent to cash drawer and then output pin 2;
m=1/49 Impulse sent to cash drawer and then output pin 5.

【Applicable version】
SDK 1.0.0 or higher.

【Example】
mCmdBuffer[mIndex++] = 0x1B;
mCmdBuffer[mIndex++] = 0x70;
mCmdBuffer[mIndex++] = DrawerNumber;
mCmdBuffer[mIndex++] = pulseStartTime;
mCmdBuffer[mIndex++] = PulseEndTime;

3-2-24 - (void) Cut Paper

【Description】
Full cut paper

【Applicable version】
SDK 1.0.0 or higher.

【Example】
mCmdBuffer[mIndex++] = 0x1B;
mCmdBuffer[mIndex++] = 0x69;

3-2-25 - (void) partial Cut Paper

【Description】
Partial cut paper

【Applicable version】
SDK 1.0.0 or higher.

【Example】
mCmdBuffer[mIndex++] = 0x1B;
mCmdBuffer[mIndex++] = 0x6D;

26
3-2-26 ① - (void) Feed And Cut Paper:(Byte)Cut Mode

②- (void) Feed And Cut Paper:(Byte)Cut Mode feed:

(Byte)Feed Distance

【Range】

1 Cut Mode:RT_CUT_PARTIAL

2 Cut Mode:RT_CUT_WITHFEED
0 <= FeedDistance <= 255

【Description】
Select cut paper mode and cutting.

【Syntax】
- (void) FeedAndCutPaper:(Byte)CutMode
- (void) FeedAndCutPaper:(Byte)CutMode feed:(Byte)FeedDistance

【Example】
- (void) FeedAndCutPaper:(Byte)CutMode
Parameter: CutMode:is defined as follows:
#define RT_CUT_PARTIAL 0x31
Len :Data length
- (void) Feed And Cut Paper:(Byte)Cut Mode feed:(Byte)Feed Distance
Parameter: Cut Mode:is defined as follows:
#define RT_CUT_WITHFEED 0x42
Feed Distance:Feed points

3-2-27 Add Bar Code Print

@property(readwrite)int codeType
@property(readwrite)(NSData *) data

27
【Description】
This part is used to select barcode system and print barcode.
GS k m n d1 … dn

【Notice】
 Parameter Code Type is used to select the barcode system, which is the parameter m in
command.
 Data for input parameters d1…dn, parameter n is calculated based on the input
parameter’s number of d1…dn
 n specifies the number of bytes of bar code data, and the printer will start from the
next n-byte character data as bar code data processing.
 If n is outside the specified range, the printer stops processing the command, and
subsequent data as normal data.
 If d is outside the specified range, the printer just feed and deal with the subsequent
data as normal data.
 The command feeds according to the requirements of the bar code printing, regardless
of the line spacing set by ESC 2 or ESC 3.
 Only when the print buffer is no data, the command is valid. Otherwise the printer
deals with the subsequent data as common ones.
 After printing the bar code, this command will set print position at the beginning of the
line.
 The command is not effected by print mode(bold overlap, underline, character size,
reverse print or characters 90 ° rotation, etc.),except upside-down printing mode.
 The command is not effected by print mode(bold overlap, underline, character size,
reverse print or characters 90 ° rotation, etc.),except upside-down printing mode.

【Applicable Version】
SDK 1.0.0 or higher

【Example】
//******Print 1D Barcode**********//
- (void) Add BarCode Print: (int)code Type :(NS Data *)data
{
Switch (code Type){
case RT_BCS_UPCA:
[self UPCA: data];
break;
case RT_BCS_UPCE:
[self UPCE: data];
break;
case RT_BCS_EAN13:
[self EAN13:data];

28
break;
case RT_BCS_EAN8:
[self EAN8:data];
break;
case RT_BCS_CODE39:
[self CODE39:data];
break;
case RT_BCS_ITF:
[self ITF: data];
break;
case RT_BCS_CODABAR:
[self CODEBAR: data];
break;
case RT_BCS_CODE93:
[self CODE93:data];
break;
case RT_BCS_CODE128:
[self Code128_B:data];
break;
default :
break;
}
}

3-2-28 Begin Print Image

@property (read write) (UIImage *) image

【Description】
This part is used to handle bitmap data.

【Applicable Version】
SDK 1.0.0 or higher

【Example】
CG Image Ref image ref = [image CG Image];
CG Color Space Ref color space = CG Color Space Create Device Gray();
CG Context Ref cg cnt = CG Bit map Context Create (image Data, width, height, …);
CG Rect there ct = CG Rect Make (0, 0, width, height);
CG Con text Draw Image (cg cnt, there ct, image ref);
CG Color Space Release(color space);
CG Context Release (cg cnt);

29
// Parse picture, get the bitmap data

//Bitmap data processing

// Send print pictures preamble command
Byte start[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x40, 0x1B, 0x33, 0x00};
NS Data *data Start = [NS Data data With Bytes : start length : 13];
[self Begin];
[self Import Data : data Start Len : [data Start length];
[self Excute];
[self Clear Data];
//Send picture data
[self Import Data : final Data Len : [final Data length]];
[self Excute];
[self Clear Data];
//Transmit complete demand
Byte end[] = {0x1d, 0x4c, 0x1f, 0x00};
NS Data *data End = [NS Datra data With Bytes : end length : 4];
[self Import Data : data End Len : [data End length]];
[self Excute];
[self Clear Data];

3-3 Instance Methods

3-3-1 Begin

【Description】
This is used to initialize the printer and configure application environment.

【Syntax】
-(void) Begin

【Applicable Version】
SDK 1.0.0 or higher

【Example】
[self Wake Up Printer];
[self Init Printer];
//Clear the printer buffer

30
[self Clear Data];

3-3-2 Excute

【Description】
This part is for execution of processing data.

【Applicable Version】
SDK 1.0.0 or higher

【Example】
NS Data *data = [[NS Data alloc] init WithBytes : mCmd Buffer length : mIndex];
[self send Data : data]
M Index = 0;

3-3-3 Import Data

【Description】
This part is for inputting printing data.

【Syntax】
-(void)Import Data : (NS Data *)data Len : (int) len
-(void)Import Data : (NS String *)data

【Example】
-(void)Import Data : (NS Data *)data Len : (int) len
Parameter: data :content of data
Len :length of data
-(void)Import Data : (NS String *)data
Parameter: data :print character string data

3-3-4 Clear Data

【Description】
Execute Clear Data() for data buffer area after execution of Execute printing.

【Syntax】
-(void)Clear Data

31
3-3-5 btn Connect

【Description】
This part is used for connect/disconnect printer connection.

【Syntax】
-(IB Action)btn Connect
-(void)on Connected
-(void)on Disconnected

【Example】
//on Connected
if(is Succeed)
{
[btn set Title : LANG(@”disconnect”) for State : UI Control State Normal];
Lab Status. text = LANG(@”connect”);
}
else {
MSGBOX(LANG(@”connection failed”));
}
//on DisConnected
if(is Succeed)
{
[btn set Title : LANG(@”connection”) for State : UI Control State Normal];
Lab Status. text = LANG(@”disconnected”);
}
else {
MSGBOX(LANG(@”disconnection failed”));
}

3-3-6 btnPrint

【Description】
This part is for testing simple printer functions.

【Syntax】
-(IB Action)btn Print

【Applicable Version】
SDK 1.0.0 or higher

【Example】

32
if(sw Double Width. Is On){
[printer Set Zoom : (Byte)0x10];
}
if(sw Double Height. isOn){
[printer Set Zoom : (Byte)0x01];
}
If (sw Under Line. is On){
[printer Set Underline : (Byte)0x02];
}
If (sw Bold. is On){
[printer Add Bold : (Byte)0x01];
}
If (sw Small Font. Is On){
[printer Set Character Font : (Byte)0x01];
}
If (sw To White. is On){
[printer Add Inverse : (Byte)0x01];
}

3-3-7 btn Preferences Click

【Description】
This part is to select the test program print characters, pictures, bar codes, invoices or forms.

【Syntax】
-(IB Action)btn Preferences Click
-(IB Action)btn Print T ext
-(IB Action)btn Print Pic
-(IB Action)btn Print Barcode
-(IB Action)btn Print Invoice
-(IB Action)btn Print Table

【Applicable】
SDK 1.0.0 or higher

【Example】
//btn Preferences Click
Preferences *pref = [[Preferences alloc]init];
pref. printer = self. printer;

App Delegate *app = [[UI Application shared Application]delegate];


[app. Nav Controller push View Controller : pref animated : YES];

33
//btn Print Text
if(IS_LANG_EN)
{
[printer Import Data : @ “abcd!!!!\n”];
}
else
{
[printer Import Data : @”test!!!\n”];
}
//btn PrintPic
UI Image *img = [UI Image image Named : @”**.bmp”];
[printer Begin Print Image : img];
//btn Print Barcode

//btn Print Invoice

//btn Print Table

34
4.Agreement Involved

Inherits from NS Object


Confirms to
Framework Lib Wifi Printer_ SDK.a
CF Network. framework
【Availability】 iOS 4.3 or higher
Declared Wifi Printer Delegate. h

4-1 Outline

This part is for WiFi connection protocol.

4-2 Instance Methods

4-2-1 connect Host

【Description】
This part is for Wifi connection.

【Syntax】
-(void)connect Host : (NS String *)host PORT : (UInt16)prot
- ( void ) on Socket : (Async Socket *)sock did Connect To Host : (NS String *)host port :
(UInt16)port

【Applicable Version】
SDK 1.0.0 or higher

【Example】
//connect Host
if(![async Socket connect To Host : host on Port : port with Timeout : TIMEOUT error : &err])
{
NSLog(@”Error: %@”, err);
}
[NS Thread detach New Thread Selector : @selector(thread Func:) to Target : self with Object :
@”CONN”];

35
//did Connect To Host
NS Log(@”connected.”);
if([delegate responds To Selector : @selector(on Connected:)])
{
[delegate on Connected : TRUE];
}

4-2-2 disconnect

【Description】
This part is for WiFi disconnection.

【Syntax】
-(void)disconnect

【Applicable Version】
SDK 1.0.0 or higher

【Example】
B DisconnOK = FALSE;
If ([async Socket is Connected])
{

}
Else
{
B DisconOK = TRUE;
if([delegate responds To Selector : @selector(on Disconnected:)])
{
[delegate on Disconnected : TRUE];
}
}

5.Appendix

【Part of product catalog】


Model Port Type
RP80 Parallel/Serial/USB/Ethernet Thermal Receipt Printer

36
RP58 USB/Serial/Parallel Thermal Receipt Printer
RP58E USB/Serial/Parallel Thermal Receipt Printer
RP80W WIFI WIFI printer
RPP-02 Original IR,VIR,IrDA(Ir Portable printer
COMM)RS232 interface,blue
tooth
RP203 Serial(RS-232C,TTL) Panel thermal printer
RP07 Serial(RS-232C,TTL) Panel thermal printer
RP76 Serial/Parallel/USB/cash port Impact printer
RP76II Serial/Parallel/USB/cash port Impact printer
PM628 Printer module
PM65C Printer module
PM532 Printer module
CT628 Paper cutter
CB628 Control board
CB1245 Control board

37

You might also like