EPOS-Print SDK Android en RevP
EPOS-Print SDK Android en RevP
User’s Manual
Overview
Describes the features and development
environment.
Sample Program
Describes how to use the sample program.
Programming Guide
Describes how to write programs in application
development.
API Reference
Describes the APIs provided in ePOS-Print SDK
for Android.
Command Transmission/Reception
Describes the APIs for transmitting and
receiving commands.
Appendix
Describes the specifications for printers used for
the ePOS-Print SDK for Android.
M00048915
Rev.P
Cautions
• No part of this document may be reproduced, stored in a retrieval system, or transmitted in any form or
by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written
permission of Seiko Epson Corporation.
• The contents of this document are subject to change without notice. Please contact us for the latest
information.
• While every precaution has taken in the preparation of this document, Seiko Epson Corporation assumes
no responsibility for errors or omissions.
• Neither is any liability assumed for damages resulting from the use of the information contained herein.
• Neither Seiko Epson Corporation nor its affiliates shall be liable to the purchaser of this product or third
parties for damages, losses, costs, or expenses incurred by the purchaser or third parties as a result of:
accident, misuse, or abuse of this product or unauthorized modifications, repairs, or alterations to this
product, or (excluding the U.S.) failure to strictly comply with Seiko Epson Corporation's operating and
maintenance instructions.
• Seiko Epson Corporation shall not be liable against any damages or problems arising from the use of any
options or any consumable products other than those designated as Original Epson Products or Epson
Approved Products by Seiko Epson Corporation.
Trademarks
EPSON is a registered trademark of Seiko Epson Corporation.
Exceed Your Vision and ESC/POS are registered trademarks or trademarks of Seiko Epson Corporation.
AndroidTM is trademark of Google Inc. in the United States and other countries.
JavaTM is a registered trademark of Oracle Corporation, its subsidiaries, and affiliates in the U.S. and other
countries.
Wi-Fi® is a registered trademark of the Wi-Fi Alliance®.
The Bluetooth® word mark and logos are registered trademarks owned by Bluetooth SIG, Inc. and any use
of such marks by Seiko Epson Corporation is under license.
Eclipse® is a trademark or registered trademark of Eclipse Foundation, Inc.
QR Code® is a registered trademark of DENSO Wave Incorporated.
All other trademarks are the property of their respective owners and used for identification purpose only.
2
For Safety
Key to Symbols
The symbols in this manual are identified by their level of importance, as defined below. Read the following
carefully before handling the product.
Provides information that must be observed to avoid damage to your equipment or a mal-
function.
Restriction of Use
When this product is used for applications requiring high reliability/safety such as transportation devices
related to aviation, rail, marine, automotive etc.; disaster prevention devices; various safety devices etc; or
functional/precision devices etc, you should use this product only after giving consideration to including fail-
safes and redundancies into your design to maintain safety and total system reliability. Because this product
was not intended for use in applications requiring extremely high reliability/safety such as aerospace
equipment, main communication equipment, nuclear power control equipment, or medical equipment
related to direct medical care etc, please make your own judgment on this product's suitability after a full
evaluation.
3
About this Manual
Manual Content
The manual is made up of the following sections:
Chapter 1 Overview
Chapter 2 Sample Program
Chapter 3 Programming Guide
Chapter 4 API Reference
Chapter 5 Command Transmission/Reception
Appendix List of Supported APIs for Each Printer Model
Support Information by Printer
Cautions
Open Source Software License Agreement
4
Contents
■ For Safety .............................................................................................................................. 3
Key to Symbols ....................................................................................................................................... 3
■ Restriction of Use .................................................................................................................. 3
■ About this Manual ................................................................................................................ 4
Aim of the Manual ................................................................................................................................. 4
Manual Content .................................................................................................................................... 4
■ Contents................................................................................................................................ 5
Overview ........................................................................................9
■ Overview of ePOS-Print SDK ................................................................................................ 9
Features................................................................................................................................................... 9
Function ................................................................................................................................................ 10
■ Operating Environment ..................................................................................................... 11
Android Version .................................................................................................................................... 11
Android Device .................................................................................................................................... 11
Printer .................................................................................................................................................... 12
Development Environment................................................................................................................. 12
■ Contents in the Package................................................................................................... 13
Package ............................................................................................................................................... 13
Manual .................................................................................................................................................. 13
Sample Program .................................................................................................................................. 13
Download ............................................................................................................................................. 14
■ Restrictions.......................................................................................................................... 14
5
Programming Guide.................................................................... 29
■ How to Incorporate the ePOS-Print SDK for Android....................................................... 29
■ ePOS-Print SDK.................................................................................................................... 31
Print Mode .............................................................................................................................................31
Programming Flow................................................................................................................................31
Advance Preparations (USB Connection).........................................................................................32
Printer Selection ....................................................................................................................................33
Print Document Creation ....................................................................................................................36
Transmission of Print Document...........................................................................................................39
Printing After Checking the Printer Status..........................................................................................41
■ Automatic Acquisition of Printer Status ............................................................................ 43
Listener Interface List ............................................................................................................................44
■ Exception handling............................................................................................................ 46
Steps for Handling.................................................................................................................................47
Error Statuses and Actions to Take ......................................................................................................49
Printer Statuses and Actions to Take...................................................................................................51
Battery Status ........................................................................................................................................53
6
addPulse ............................................................................................................................................. 108
addSound ........................................................................................................................................... 109
addSound (Previous format)............................................................................................................. 111
addFeedPosition ................................................................................................................................ 113
addLayout .......................................................................................................................................... 114
addCommand................................................................................................................................... 116
Print class (Constructor) .................................................................................................................... 117
Print class (Constructor)(Previous format) ....................................................................................... 118
openPrinter ......................................................................................................................................... 119
openPrinter (Previous format)........................................................................................................... 121
openPrinter (Previous format)........................................................................................................... 124
closePrinter ......................................................................................................................................... 126
sendData ............................................................................................................................................ 127
sendData (Previous format).............................................................................................................. 129
beginTransaction ............................................................................................................................... 131
endTransaction .................................................................................................................................. 132
setStatusChangeEventCallback ...................................................................................................... 133
setOnlineEventCallback.................................................................................................................... 134
setOfflineEventCallback.................................................................................................................... 135
setPowerOffEventCallback ............................................................................................................... 136
setCoverOkEventCallback ............................................................................................................... 137
setCoverOpenEventCallback .......................................................................................................... 138
setPaperOkEventCallback ............................................................................................................... 139
setPaperNearEndEventCallback ..................................................................................................... 140
setPaperEndEventCallback.............................................................................................................. 141
setDrawerClosedEventCallback ...................................................................................................... 142
setDrawerOpenEventCallback ........................................................................................................ 143
setBatteryLowEventCallback ........................................................................................................... 144
setBatteryOkEventCallback ............................................................................................................. 145
setBatteryStatusChangeEventCallback ......................................................................................... 146
getStatus ............................................................................................................................................. 147
getErrorStatus...................................................................................................................................... 148
getPrinterStatus .................................................................................................................................. 149
getBatteryStatus................................................................................................................................. 150
■ Printer Search API............................................................................................................. 151
start ...................................................................................................................................................... 152
stop ...................................................................................................................................................... 153
getDeviceinfolist................................................................................................................................. 154
getResult (Previous format) ............................................................................................................... 156
getStatus ............................................................................................................................................. 157
■ Printer Easy Select API ..................................................................................................... 158
parseNFC ............................................................................................................................................ 159
parseNFC (Previous format).............................................................................................................. 160
parseQR .............................................................................................................................................. 160
createQR ............................................................................................................................................ 161
deviceType ......................................................................................................................................... 162
printerName ....................................................................................................................................... 162
macAddress ....................................................................................................................................... 162
■ Log Setting API.................................................................................................................. 163
setLogSettings..................................................................................................................................... 163
7
Command Transmission/Reception ........................................ 167
■ Programming.................................................................................................................... 167
Programming Flow..............................................................................................................................167
Opening a Device Port ......................................................................................................................168
Sending Data ......................................................................................................................................168
Receiving Data...................................................................................................................................169
Closing the Device Port .....................................................................................................................169
Exception handling ............................................................................................................................170
■ Command Transmission/Reception API Reference...................................................... 171
open.....................................................................................................................................................171
open(Previous format) .......................................................................................................................173
close.....................................................................................................................................................174
write .....................................................................................................................................................175
read......................................................................................................................................................176
Appendix.................................................................................... 177
■ List of Supported APIs for Each Printer Model ................................................................ 177
■ Support Information by Printer ........................................................................................ 178
TM-m10 ................................................................................................................................................178
TM-P20 (ANK model / Multi-language model)................................................................................180
TM-P60..................................................................................................................................................182
TM-P60II/ TM-P60II with Peeler (ANK model / Multi-language model)..........................................184
TM-P80 (ANK model / Multi-language model)................................................................................186
TM-T20 ..................................................................................................................................................188
TM-T20II.................................................................................................................................................189
TM-T70 (ANK model)...........................................................................................................................190
TM-T70 (Multi-language model)........................................................................................................191
TM-T70II (ANK model) .........................................................................................................................192
TM-T70II (Multi-language model) ......................................................................................................193
TM-T81II.................................................................................................................................................195
TM-T82 ..................................................................................................................................................196
TM-T82II (ANK model / Multi-language model)...............................................................................197
TM-T83II.................................................................................................................................................199
TM-T88V (ANK model / Multi-language model)..............................................................................200
TM-T90II.................................................................................................................................................202
TM-U220 ...............................................................................................................................................203
TM-U330 ...............................................................................................................................................205
■ Cautions ............................................................................................................................ 206
If you Use the Printer from Multiple Mobile Terminals .....................................................................206
To specify a transaction.....................................................................................................................208
■ Open Source Software License Agreement .................................................................. 209
8
Chapter 1 Overview
Overview
This chapter describes the features of and the specifications for ePOS-Print SDK for Android.
1
The ePOS-Print SDK for Android is an SDK aimed at development engineers who are developing AndroidTM
applications for printing on an Epson TM printer. Applications are developed using the APIs provided by
ePOS-Print SDK.
The ePOS-Print SDK also has the "ePOS-Print SDK for iOS" for iOS applications.
Features
❏ Allows printing to TM printers from Android applications.
9
Function
ePOS-Print API
❏ Print setting (alignment/line feed space/text rotation/page mode)
❏ Barcode printing
(For barcodes that can be printed by each model, refer to Support Information by Printer (p.178).)
❏ 2D-Code printing
(For 2D-Code that can be printed by each model, refer to Support Information by Printer (p.178).)
❏ Buzzer function
❏ Acquisition of response from printer (printing result / printer status / battery status)
❏ Compatible with Asian languages (simplified Chinese, traditional Chinese, Korean, Thai, Vietnamese)
Log data output to an Android device can be saved on other computers using a USB
connection.
10
Chapter 1 Overview
Operating Environment
Android Version
❏ Android Version 2.3.3 to 2.3.7
❏ Android Version 3.1 to 3.2.2
❏ Android Version 4.0 to 4.4
❏ Android Version 5.0 to 5.1
11
Printer
Interface
TM Printer
Wired LAN Wi-Fi® Bluetooth® USB
TM-m10 ✔ - - ✔
TM-P20 - ✔ ✔ ✔
TM-P60[Receipt] Wi-Fi - ✔ - -
TM-P60[Receipt] Bluetooth - - ✔ -
TM-P60[Peeler] Wi-Fi - ✔ - -
TM-P60[Peeler] Bluetooth - - ✔ -
TM-P60II[Receipt] Wi-Fi - ✔ - ✔
TM-P60II[Receipt] Bluetooth - - ✔ ✔
TM-P60II[Peeler] Wi-Fi - ✔ - ✔
TM-P60II[Peeler] Bluetooth - - ✔ ✔
TM-P80 Wi-Fi - ✔ - ✔
TM-P80 Bluetooth - - ✔ ✔
TM-T20 ✔ - - ✔
TM-T20II ✔ - ✔ ✔
TM-T70 ✔ ✔ - ✔
TM-T70II ✔ ✔ ✔ ✔
TM-T81II ✔ - - ✔
TM-T82 ✔ - - ✔
TM-T82II ✔ - - ✔
TM-T83II ✔ - - ✔
TM-T88V ✔ ✔ ✔ ✔
TM-T90II ✔ ✔ - ✔
TM-U220 Series ✔ ✔ - ✔
TM-U330 Series ✔ ✔ - ✔
In the TM printer settings, set only Receive Buffer Full for the Busy Condition.
Regarding the settings, see the Technical Reference Guide for the printer.
Development Environment
The following are necessary to develop an Android application.
Android SDK r15 or later
Java Development Kit 6 or later
12
Chapter 1 Overview
Package
File Description
Compiled Java class file, archived into a jar format file to allow
ePOS-Print.jar
APIs to be used from Java programs.
ePOSEasySelect.jar A Java class file for selecting a printer easily.
libeposprint.so Library for function execution. (ARMv5TE supported)
libeposeasyselect.so
Library for the ePOSEasySelect function execution.
(ARMv5TE supported) 1
ePOS-Print_Sample_Android.zip A sample program file.
README.en.txt A readme file.
README.jp.txt A readme file. (The Japanese-language edition)
EULA.en.txt Contains the SOFTWARE LICENSE AGREEMENT.
Contains the SOFTWARE LICENSE AGREEMENT.
EULA.jp.txt
(The Japanese-language edition)
ePOS-Print_SDK_Android_en_revx.pdf This manual.
ePOS-Print_SDK_Android_ja_revx.pdf The Japanese-language edition of this manual.
ePOS-Print_SDK_Android_ D e s c r i b es t h e pro c e d u r e fo r bu i l d i n g a d eve l o pm e n t
AppDevGuide_en_revx.pdf environment.
ePOS-Print_SDK_Android_ D e s c r i b es t h e pro c e d u r e fo r bu i l d i n g a d eve l o pm e n t
AppDevGuide_ja_revx.pdf environment. (The Japanese-language edition)
Manual
The following manuals are available for ePOS-Print SDK for Android.
❏ ePOS-Print SDK for Android User's Manual (This Document)
Sample Program
For an Android application for TM printers developed using ePOS-Print SDK for Android, the following
program is available.
❏ ePOS-Print_Sample_Android.zip
13
Download
For customers in North America, go to the following web site:
http://www.epsonexpert.com/
For customers in other countries, go to the following web site:
https://download.epson-biz.com/?service=pos
Restrictions
❏ A communication API (p.57) and command transmission/reception API (p.167) in the ePOS-Print APIs
cannot be used for the same device at the same time.
❏ A maximum of 16 device ports can be opened in the same application at the same time.
❏ When the screen display rotates, Activity may be discarded. To retain a Print instance using Activity,
closePrinter of the Print class should be called before Activity is discarded.
❏ If the device goes into sleep mode while communicating with a printer via Bluetooth, the connection
will be lost.
14
Chapter 2 Sample Program
Sample Program
This chapter describes how to use the sample program.
• The sample program is provided as an Android application project for use with Eclipse,
including the Java source files.
• For an Android application for TM printers developed using ePOS-Print SDK, the following
program is available.
Overview
The Sample Program has the following functionality.
15
Sample Program Description
<ePOSReceiptPrintSample> Prints the sample receipt data.
Searching for printers
Receipt printing
16
Chapter 2 Sample Program
Usage Environment
Development Environment
Android SDK r16
Java Development Kit 6
Eclipse
ADT Plugin for Eclipse
For details about ways to construct a development environment, please refer to the "ePOS-Print
SDK for Android Application Development - Setup Guide".
Printer
TM printer supported in ePOS-Print SDK.
2
Target device
Device connected to a computer via USB
17
Environmental Construction
Follow the procedures below to use the sample program.
3 The Import Projects window will be displayed. Make the settings shown below and
click [Finish].
Item Setting
Specify the directory where you extracted the sample program
Select root directory
zip file.
Copy projects into workspace Check this option.
7 The sample program will be installed to the target Android device, and then the
program will start up.
18
Chapter 2 Sample Program
6 Tap [Open].
19
7 Execute the following processes:
Process Description
Tap [Text] on the main screen.
Text printing
For details, refer to Text printing (p.21).
Tap [Image] on the main screen.
Graphic printing
For details, refer to Graphic printing (p.21).
Tap [Barcode] on the main screen.
Barcode printing
For details, refer to Barcode printing (p.22).
Tap [2D Code] on the main screen.
2D-Code printing
For details, refer to 2D-Code printing (p.22).
Tap [Page Mode] on the main screen.
Printing in page mode
For details, refer to Printing in page mode (p.23).
Tap [Cut] on the main screen.
Paper cutting
For details, refer to Paper cutting (p.23).
Tap [Log Settings] on the main screen.
Log output setting
For details, refer to Log output setting (p.23).
Printer status acquisition Tap [Get Status] on the main screen.
9 When all processing is finished, tap [Close] on the main screen, and close the
printer's port.
20
Chapter 2 Sample Program
Text printing
Execute the text printing according to the following procedure:
2 Specifies the character properties for the string to print. The following properties
can be specified:
Property Description
Font Set the character font.
Align Set the alignment.
Line Spacing Set the line feed space.
Language Set the language.
Size Set the character scales (vertical / horizontal).
Style Set the character style (bold / underlining).
X Position
Feed Unit
Set the horizontal start position.
Set the paper feed amount.
2
3 Tap [Print] to print.
Graphic printing
Execute the graphic printing according to the following procedure:
[Gray 16] is supported by models that support multiple tones. For details, see addImage
(p.78).
21
Barcode printing
Execute the barcode printing according to the following procedure:
2D-Code printing
Execute the 2D-Code printing according to the following procedure:
22
Chapter 2 Sample Program
Paper cutting
Execute the paper cutting according to the following procedure: 2
1 Set whether to cut after feeding paper using [Type].
1 Set whether to enable the log output function and the log output destination in
[Enabled].
23
Execution result
Process execution result
Any of the following will be displayed:
Result: Any of the following statuses will be displayed:
24
Chapter 2 Sample Program
25
Acquisition of Printer Model Name
A command transmission/reception API is used for acquisition of printer model name. For details,
refer to Command Transmission/Reception (p.167).
1 Start the sample program. For details, refer to Environmental Construction (p.18).
26
Chapter 2 Sample Program
1 Start the sample program. For details, refer to Environmental Construction (p.18).
2 Tap [Quick pairing and Easy print by NFC/QR code] on the main screen.
QR Code Printing
2
Use the following procedure:
1 Start the sample program. For details, refer to Environmental Construction (p.18).
27
Sample receipt data Printing
Use the following procedure:
1 Start the sample program. For details, refer to Environmental Construction (p.18).
2 Search for printers. Tap [Printer Discovery / Select] on the main screen.
Select [Interface Type] to display a list of IP addresses/ Mac addresses/ Device
nodes/ Printer names for the printers retrieved on the [Printer List].
28
Chapter 3 Programming Guide
Programming Guide
This chapter describes how to write programs in the application development using ePOS-Print SDK.
For ways to construct a development environment for Android applications that use ePOS-Print
SDK for Android, please refer to the "ePOS-Print SDK for Android Application Development -
Setup Guide".
This explanation uses Eclipse. If you are using another development environment, please make
the appropriate changes.
2 Copy provided JAR file (ePOS-Print.jar and ePOSEasySelect.jar) into following path:
3
libs
ePOS-Print.jar
ePOSEasySelect.jar
3 In Libraries tab of the target project's properties, confirm that the JAR file you
added (ePOS-Print.jar) is registered in [Java Build Path].
If it has not been added, add the JAR file into build path using [Add Jars...].
4 Copy the library file (libeposprint.so and libeposeasyselect.so) into following path:
libs
armeabi
libeposprint.so
libeposeasyselect.so
5 Select the project in Eclipse's Package Explorer, right click on it, and press [Refresh].
29
6 Write the package import declaration in the *.java source file(s) of the application
you would like to use this SDK in as follows:
import com.epson.eposprint.*;
import com.epson.epsonio.*;
import com.epson.easyselect.*;
There is no need to define the easyselect package if Printer Easy Select is not used.
7 Confirm that the target project's "/libs" folder is in the Source tab of the target
project's properties. If not, add "libs" to the build path using [Add Folder...].
8 With the target project selected from Eclipse's Package Explorer, select
[Preferences] in the [Window] menu.
9 The [Preferences] screen is displayed. From the list on the left, select [Java]-
[Compiler].
10 The [Compiler] screen is displayed. Set the [Compiler compliance level:] to "1.6",
and click [Apply]. After that, click [OK].
There is one setting of permissions for function that can be attached per [Uses Permission]
in [Permissions]. For using the Bluetooth function and all functions, you must repeat
settings from procedures 13 to 15.
16 Save "AndroidManifest.xml".
30
Chapter 3 Programming Guide
ePOS-Print SDK
Print Mode
There are two types of print modes: standard and page modes.
Standard mode
In standard mode, characters are printed line by line. The line feed space is adjusted based on the font size
and the height of images, barcodes, etc. This mode is suitable for the type of printing such as printing
receipts that requires the paper length to change according to the print space.
Page mode
In page mode, you set a print area, lay out data in it, and print the data in a batch operation. Characters,
images, and barcodes are laid out in the print positions (coordinates).
Programming Flow
Perform programming following this flow.
To ensure successful print operation, write a program in such a way that data is sent after
checking the printer status. For the above procedure, refer to Printing After Checking the Printer
Status (p.41).
31
Advance Preparations (USB Connection)
For a USB interface, we recommend obtaining access permission to USB devices in the application.
To open a port using the openPrinter method without obtaining access permission to USB devices
in advance, note the following:
• When [OK] is pressed in the dialog box for access permission acquisition, it takes about 10
seconds to open a port.
• When [Cancel] is pressed in the dialog box for access permission acquisition, the state of
waiting for the timeout lasts for 30 seconds.
<manifest ...>
<application>
<activity ...>
<intent-filter>
<action android:name
="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<meta-data android:name
="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
</activity>
</application>
</manifest>
32
Chapter 3 Programming Guide
Printer Selection
//Start search
try {
switch(deviceType){
//Wi-Fi/Ethernet device
case DevType.TCP:
Finder.start(getBaseContext(), DevType.TCP, "255.255.255.255");
break;
//Bluetooth device
case DevType.BLUETOOTH:
Finder.start(getBaseContext(), DevType.BLUETOOTH, "null");
break;
//USB device
case DevType.USB:
Finder.start(getBaseContext(), DevType.USB, "null");
break;
default:
Finder.start(getBaseContext(), DevType.TCP, "255.255.255.255");
break;
}
//Exception handling
} catch ( EpsonIoException e ) {
errStatus = e.getStatus();
3
}
Since the printer search takes time to complete, you might not receive any search results
if you call the Finder class's getDeviceInfoList immediately after you call start.
33
Stopping the printer search
Use the Finder class's stop (p.153) to stop searching for printers. Please refer to the following code.
//Stop search
try {
Finder.stop();
//Exception handling
} catch ( EpsonIoException e ) {
errStatus = e.getStatus();
}
@Override
protected void onNewIntent(Intent intent) {
try {
Print printer = new Print();
///Printing process///
printer.closePrinter();
} catch (EposException e) {
///Process///
}
}
34
Chapter 3 Programming Guide
try {
Print printer = new Print();
printer.closePrinter();
//Exception handling
} catch (EposException e) {
///Process///
}
3
How to Create Printer Easy Select QR code
❏ For models that can automatically print Printer Easy Select QR code
Use the QR code for dynamic status sheets.
For details on how to print dynamic status sheets, refer to the Technical Reference Guide of each model.
❏ For models that cannot automatically print Printer Easy Select QR code
Create QR code using createQR (p.161).
Refer to QR code creation in the sample program.
35
Print Document Creation
Create a print document using the Builder class (p.55).
Create a Builder class using the constructor for it and create a print document using APIs of the Builder
class. Use the programming example below for your reference.
try {
//Initialize a Builder class instance
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
//Create a print document
builder.addTextLang(Builder.LANG_EN);
builder.addTextSmooth(Builder.TRUE);
builder.addTextFont(Builder.FONT_A);
builder.addTextSize(3, 3);
builder.addText("Hello,\t");
builder.addText("World!\n");
builder.addCut(Builder.CUT_FEED);
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
Make the language settings based on the language of the characters you are printing.
For details, refer to addTextLang (p.68).
For the string "Hello, World!", to create a print document based on the following settings:
Font: FontA
Scale: x 4 (horizontal) and x 4 (vertical)
Style: Bold
try {
//Initialize a Builder class instance
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
//Create a print document
//<Configure the print character settings>
builder.addTextLang(Builder.LANG_EN);
builder.addTextSmooth(Builder.TRUE);
builder.addTextFont(Builder.FONT_A);
builder.addTextSize(4, 4);
builder.addTextStyle(Builder.FALSE, Builder.FALSE, Builder.TRUE,
Builder.PARAM_UNSPECIFIED);
//<Specify the print data>
builder.addText("Hello,\t");
builder.addText("World!\n");
builder.addCut(Builder.CUT_FEED);
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
36
Chapter 3 Programming Guide
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
try {
//Initialize a Builder class instance
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
//Create a print document
Bitmap bmp = BitmapFactory.decodeResource(getResources(),R.drawable.background);
builder.addImage(bmp, 0, 0, 8, 48, Builder.PARAM_DEFAULT);
builder.addCut(Builder.CUT_FEED);
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
For ways of graphic printing, you can also print the graphics registered in the printer's NV memory.
For details, refer to addLogo (p.86).
37
To create a page mode print document
The page mode starts by storing addPageBegin (p.97) of the Builder class into a command buffer. Store the
print area (addPageArea (p.99)) and the print start position (addPagePosition (p.102)) in command buffers.
Specify the print start position according to the print data. Then, store APIs in command buffers and create
print data. For the page mode end, store addPageEnd (p.98) in a command buffer. Use the programming
example below for your reference.
Make the language settings based on the language of the characters you are printing.
For details, refer to addTextLang (p.68).
For the string "Hello, World!", to create a print document based on the following settings:
Page mode print area (in dots):
Origin of horizontal axis: 100, origin of vertical axis: 50, width: 200, height: 100
Page mode print positions (in dots):
Horizontal print position: 0, vertical print position: 42
Font: FontA
Scale: x 2 (horizontal) and x 2 (vertical)
Style: Bold
try {
//Initialize a Builder class instance
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
//Create a print document
//<The page mode starts>
builder.addPageBegin();
builder.addPageArea(100, 50, 200, 100);
builder.addPagePosition(0, 42);
//<Configure the print character settings>
builder.addTextLang(Builder.LANG_EN);
builder.addTextSmooth(Builder.TRUE);
builder.addTextFont(Builder.FONT_A);
builder.addTextSize(2, 2);
builder.addTextStyle(Builder.FALSE, Builder.FALSE, Builder.TRUE,
Builder.PARAM_UNSPECIFIED);
//<Specify the print data>
builder.addText("Hello,\t");
builder.addText("World!\n");
//<The page mode ends>
builder.addPageEnd();
builder.addCut(Builder.CUT_FEED);
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
38
Chapter 3 Programming Guide
If you want to print the same document repeatedly, you don't have to execute
clearCommandBuffer.
try {
//Initialize a Builder class instance
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
//Create a print document
//<The page mode starts>
builder.addTextLang(Builder.LANG_EN);
builder.addTextSmooth(Builder.TRUE);
builder.addTextFont(Builder.FONT_A);
builder.addTextSize(4, 4);
3
builder.addTextStyle(Builder.FALSE, Builder.FALSE, Builder.TRUE, Builder.PARAM_UNSPECIFIED);
//<Specify the print data>
builder.addText("Hello,\t");
builder.addText("World!\n");
builder.addCut(Builder.CUT_FEED);
//Send a print document
//<Start communication with the printer>
////Wi-Fi/Ethernet device
printer.openPrinter(mList.getDeviceType(), mList.getDeviceName());
////USB device
printer.openPrinter(mList.getDeviceType(), mList.getDeviceName(), "null", Print.TRUE,
Print.PARAM_DEFAULT);
////USB device
printer.openPrinter(mList.getDeviceType(), mList.getDeviceName(), getApplicationContext(),
Print.TRUE, Print.PARAM_DEFAULT);
//<Send data>
printer.sendData(builder, 10000, status);
//<Delete the command buffers>
if((status[0] & Print.ST_PRINT_SUCCESS) == Print.ST_PRINT_SUCCESS)
{
builder.clearCommandBuffer();
}
//<End communication with the printer>
printer.closePrinter();
} catch (EposException e) {
int errStatus = e.getErrorStatus();
status[0] = e.getPrinterStatus();
printer.closePrinter();
}
39
Effective range of command buffers for setting
The effective range of addXXX in the Builder class instance used for setting is from the time when addXXX is
set until sendData is executed. The set value is initialized each time sendData is executed.
Refer to the following:
Example:
40
Chapter 3 Programming Guide
int retry = 0;
3
try {
//Initialize an EposPrint class instance
printer = new Print();
//Start communication with the printer
printer.openPrinter(Print.DEVTYPE_TCP, "192.168.192.168");
}
catch (EposException e) {
printer = null;
continue;
}
try {
//<Get printer status>
printer.getStatus(status, battery);
[2]
if ((status[0] & Print.ST_OFF_LINE) != Print.ST_OFF_LINE) {
//<Send print data> [3]
printer.sendData(builder, 10000, status, battery);
}
else if ((status[0] & Print.ST_OFF_LINE) == Print.ST_OFF_LINE) {
;
}
else { [4]
;
}
}
catch (EposException e) {
errStatus = e.getErrorStatus();
status[0] = e.getPrinterStatus();
battery[0] = e.getBatteryStatus();
}
finally {
//<End communication with the printer>
printer.closePrinter();
printer = null;
}
if (errStatus != EposException.ERR_CONNECT) {
break;
}
}
builder.clearCommandBuffer();
builder = null;
41
1 Create print data.
3 When the printer status is online, send the print data you created in step 1.
4 When the printer status is offline, clear the factor that is making the printer status
offline. (Such as cover open and no paper.)
42
Chapter 3 Programming Guide
}
}
int errStatus = e.getErrorStatus();
printer.closePrinter();
3
}
When printer status notification is ended, it ends on the closePrinter (p.126) of the Print
class.
43
Listener Interface List
For details on the listener interface, refer to API Reference (p.55), which explains the
notification destination registration API.
Event listener
Function Notification destination method
Notification destination registration API
public interface StatusChangeEventListener extends EventListener
Printer status notification void onStatusChangeEvent(String deviceName, int status)
setStatusChangeEventCallback (p.133)
public interface OnlineEventListener extends EventListener
Online notification void onOnlineEvent(String deviceName)
setOnlineEventCallback (p.134)
public interface OfflineEventListener extends EventListener
Offline notification void onOfflineEvent(String deviceName)
setOfflineEventCallback (p.135)
public interface PowerOffEventListener extends EventListener
Power off notification void onPowerOffEvent(String deviceName)
setPowerOffEventCallback (p.136)
public interface CoverOkEventListener extends EventListener
Cover close notification void onCoverOkEvent(String deviceName)
setCoverOkEventCallback (p.137)
public interface CoverOpenEventListener extends EventListener
Cover open notification void onCoverOpenEvent(String deviceName)
setCoverOpenEventCallback (p.138)
public interface PaperOkEventListener extends EventListener
Paper OK notification void onPaperOkEvent(String deviceName)
setPaperOkEventCallback (p.139)
public interface PaperNearEndEventListener extends EventListener
Paper near end notification void onPaperNearEndEvent(String deviceName)
setPaperNearEndEventCallback (p.140)
public interface PaperEndEventListener extends EventListener
Paper end notification void onPaperEndEvent(String deviceName)
setPaperEndEventCallback (p.141)
public interface DrawerClosedEventListener extends EventListener
Drawer close notification void onDrawerClosedEvent(String deviceName)
setDrawerClosedEventCallback (p.142)
public interface DrawerOpenEventListener extends EventListener
Drawer open notification void onDrawerOpenEvent(String deviceName)
setDrawerOpenEventCallback (p.143)
public interface BatteryLowEventListener extends EventListener
Battery low notification void onBatteryLowEvent(String deviceName)
setBatteryLowEventCallback (p.144)
44
Chapter 3 Programming Guide
Event listener
Function Notification destination method
Notification destination registration API
public interface BatteryOkEventListener extends EventListener
Battery OK notification void onBatteryOkEvent(String deviceName)
setBatteryOkEventCallback (p.145)
public interface BatteryStatusChangeEventListener extends EventListener
Battery status notification void onBatteryStatusChangeEvent(String deviceName, int battery)
setBatteryStatusChangeEventCallback (p.146)
45
Exception handling
In ePOS-Print SDK for Android, it is designed that when an error occurs, a propriety exception with an integer
(int) type parameter is generated to notify the calling side of such an error. The ePOS-Print API acquires
information using the EposException class (p.58), and the search API acquires information using the
EposException class (p.58). The following errors are sent:
Type Description
Cause of error when each class's API was executed.
Error status
For details, refer to Error Statuses and Actions to Take (p.49).
Status of the printer when print data was sent.
The printer status can be acquired only when sendData (Previous
Printer status
format) (p.129) is executed.
For details, refer to Printer Statuses and Actions to Take (p.51).
Status of the printer's battery.
Battery status
For details, refer to Battery Status (p.53).
46
Chapter 3 Programming Guide
ePOS-Print API
Acquire the error status using the EposException class getErrorStatus (p.148), the printer status using
getPrinterStatus (p.149), and the battery status using getBatteryStatus (p.150).
Use the programming example below for your reference.
try {
//Create a print document
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK, getApplicationContext());
builder.addText("Hello,\t");
builder.addText("World!\n");
builder.addCut(Builder.CUT_FEED);
//<Send print data>
////Wi-Fi/Ethernet device
printer.openPrinter(mList.getDeviceType(), mList.getDeviceName(), Print.TRUE,
Print.PARAM_DEFAULT);
////Bluetooth device
3
printer.openPrinter(Print.DEVTYPE_BLUETOOTH, "00:00:12:34:56:78", Print.TRUE,
Print.PARAM_DEFAULT);
////USB device
printer.openPrinter(Print.DEVTYPE_USB, "/dev/bus/usb/001/002", Print.TRUE,
Print.PARAM_DEFAULT);
printer.sendData(builder, 10000, status, battery);
printer.closePrinter();
} catch (EposException e) {
//Acquire the error status
int errStatus = e.getErrorStatus();
//Acquire the printer status
status[0] = e.getPrinterStatus();
//Acquire the battery status
battery[0] = e.getBatteryStatus();
printer.closePrinter();
}
47
Search API
Acquire the error status using getStatus (p.157) of the EpsonIoException class.
Use the programming example below for your reference.
////Wi-Fi/Ethernet device
Finder.start(getBaseContext(), DevType.TCP, "255.255.255.255");
////Bluetooth device
Finder.start(getBaseContext(), DevType.BLUETOOTH, "null");
////USB device
Finder.start(getBaseContext(), DevType.USB, "null");
mList = getDeviceInfoList(FilterOption.PARAM_DEFAULT);
//Exception processing
} catch ( EpsonIoException e ) {
errStatus = e.getStatus();
}
48
Chapter 3 Programming Guide
49
Error status Cause Action to Take
Could not execute process.
<Example> Review the application processing
ERR_PROCESSING Could not execute the process timing so that processes do not overlap
because an identical process is being each other.
executed in another thread.
An unsupported model name or Cannot be used for unsupported
ERR_UNSUPPORTED
language specification was specified. models.
Eliminate the cause that makes the
ERR_OFF_LINE The printer is offline. printer offline.
(Such as cover open and no paper.)
Check the communication settings of
the Android device. (Wi-Fi
connection setting, Bluetooth
ERR_FAILURE An unspecified error occurred. connection, USB connection setting,
etc.)
Check that there is no problem with
the execution environment.
50
Chapter 3 Programming Guide
51
Printer Status Cause Action to Take
The motor driver IC temperature The error status is automatically
Print.ST_MOTOR_OVERHEAT * increased, causing an canceled when the temperature of
(0x20000000) automatically recoverable error. the motor driver IC drops as time
passes.
The battery temperature The error status is automatically
Print.ST_BATTERY_OVERHEAT *
increased, causing an canceled when the temperature of
(0x40000000)
automatically recoverable error. the battery drops as time passes.
Print.ST_WRONG_PAPER * The inserted paper is different Set the proper paper to match the
(0x00001000) from the layout settings. layout settings in the printer.
52
Chapter 3 Programming Guide
Battery Status
The battery status consists of the following 16 bits (0x0000).
Bit Description
Common battery status
Upper 8 bits
For details, refer to Common battery status (upper 8 bits) (p.53).
Battery status exclusive by model
Lower 8 bits
For details, refer to Support Information by Printer (p.178).
"0x0000" is returned if the battery status cannot be acquired or if the model does not support
the battery status.
53
54
Chapter 4 API Reference
API Reference
This chapter describes the APIs provided in the ePOS-Print SDK for Android.
ePOS-Print API
The ePOS-Print APIs are APIs for creating and printing print documents. The following classes are available.
The APIs that you can use and the settings that you can designate vary based on the printer.
For details, refer to List of Supported APIs for Each Printer Model (p.177) and Support Information
by Printer (p.178).
Builder class
This class creates print documents for printer control commands such as character strings to print, graphic
printing, and paper cutting. The following APIs are available.
addTextAlign
Clears the command buffers added by APIs.
64
4
addTextLineSpace Adds a tag for the line feed space setting. 65
addTextRotate Adds a tag for the text rotation setting. 66
addText Adds a tag for printing text. 67
addTextLang Adds a tag for the target language setting. 68
addTextFont Adds a tag for the text font setting. 69
Text addTextSmooth Adds a tag for the text smoothing setting. 70
Adds a tag for specifying the double-sized text
addTextDouble 71
setting.
addTextSize Adds a tag for the text scale setting. 72
addTextStyle Adds a tag for the text style setting. 73
Adds a tag for specifying the print position of
addTextPosition 75
text.
addFeedUnit Adds a tag for paper feeding (in dots). 76
Paper Feed addFeedLine Adds a tag for paper feeding (in lines). 77
addFeedPosition Adds a tag for label / black mark paper feeding. 113
55
API Description Page
Adds multiple tone raster image printing to the
command buffer.
addImage 78
Compresses image data and adds them to the
command buffer. (Bluetooth interface)
Adds multiple tone raster image printing to the
addImage command buffer.
81
Graphic (Previous format) (Image data compression cannot be used
(Bluetooth interface).)
Adds a tag for a raster image to be printed.
addImage (Image data compression cannot be used
84
(Previous format) (Bluetooth interface).
Multiple tones cannot be printed.)
addLogo Adds a tag for an NV logo to be printed. 86
addBarcode Adds a tag for a barcode to be printed. 87
Barcode
addSymbol Adds a tag for a 2D-Code to be printed. 92
addPageBegin Adds a tag for switching to page mode. 97
addPageEnd Adds a tag for finishing page mode. 98
Adds a tag for specifying the print area in page
addPageArea 99
mode.
Adds a tag for specifying the print direction in
addPageDirection 100
Page mode page mode.
Adds a tag for specifying the print position in
addPagePosition 102
page mode.
addPageLine Adds a tag for drawing a line in page mode. 103
Adds a tag for drawing a rectangle in page
addPageRectangle 105
mode.
Cut addCut Adds a tag for paper cut. 107
Drawer kick-out addPulse Adds a tag for the drawer kick-out. 108
addSound Adds a tag for turning on the buzzer. 109
Buzzer addSound Adds a tag for turning on the buzzer.
111
(Previous format) (The buzzer sounding cycle cannot be set.)
Paper Layout addLayout Adds a tag for paper layout information. 114
Send Command addCommand Adds a tag for inserting commands. 116
56
Chapter 4 API Reference
Print class
Controls the printer by sending a print document created using the Builder class, and monitors the
transmission result and the communication status.
57
EposException class
Acquires the status during slowdown when an exception occurs in printing error or an API execution error
occurs.
58
Chapter 4 API Reference
Syntax
public Builder(String printerModel, int lang,
Context context) throws EposException
Parameter
printerModel : Specifies the model name for the target printer.
59
lang : Specifies the language specifications for the printer.
TM printer-separate setting
TM-U220
TM-U330
TM-T88V
TM-P60II
TM-T20II
TM-T81II
TM-T82II
TM-T83II
TM-T70II
TM-T90II
TM-m10
TM-P20
TM-P60
TM-P80
TM-T20
TM-T82
TM-T70
Set value Printer model
Builder.
ANK ✔ ✔ ✔ ✔ ✔ ✔ ✔ - - ✔ - ✔ ✔ ✔ - ✔ -
MODEL_ANK
Builder.
Japanese ✔ ✔ - - - ✔ - - - - - ✔ ✔ ✔ ✔ ✔ -
MODEL_JAPANESE
Builder.
Simplified Chinese - ✔ - - - - - ✔ - ✔ - ✔ ✔ ✔ - ✔ ✔
MODEL_CHINESE
Builder.
Traditional Chinese ✔ ✔ - ✔ ✔ - - - - ✔ - ✔ ✔ ✔ - ✔ -
MODEL_TAIWAN
Builder.
Korean - - - - - - - - - - ✔ - ✔ ✔ - ✔ -
MODEL_KOREAN
Builder.
Thai - - - - - - - - ✔ ✔ - ✔ ✔ ✔ - ✔ -
MODEL_THAI
Builder.
South Asian - ✔ - - - - - - ✔ ✔ - ✔ ✔ ✔ - ✔ -
MODEL_SOUTHASIA
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
If you are initializing the command buffer for the TM-T88V ANK model:
import android.content.Context;
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK,
getApplicationContext());
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
60
Chapter 4 API Reference
Syntax
public Builder(String printerModel, int lang)
throws EposException
Parameter
printerModel : Specifies the model name for the target printer.
61
lang : Specifies the language specifications for the printer.
TM printer-separate setting
TM-U220
TM-U330
TM-P60II
TM-T88V
TM-T20II
TM-T70II
TM-T81II
TM-T82II
TM-T83II
TM-T90II
TM-m10
TM-P20
TM-P60
TM-P80
TM-T20
TM-T70
TM-T82
Set value Printer model
Builder.
ANK ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ - - ✔ - ✔ - ✔ -
MODEL_ANK
Builder.
Japanese ✔ ✔ - - - ✔ - ✔ ✔ - - - - ✔ ✔ ✔ -
MODEL_JAPANESE
Builder.
Simplified Chinese - ✔ - - - - - ✔ ✔ ✔ - ✔ - ✔ - ✔ ✔
MODEL_CHINESE
Builder.
Traditional Chinese ✔ ✔ - ✔ ✔ - - ✔ ✔ - - ✔ - ✔ - ✔ -
MODEL_TAIWAN
Builder.
Korean - - - - - - - - ✔ - - - ✔ ✔ - ✔ -
MODEL_KOREAN
Builder.
Thai - - - - - - - ✔ ✔ - ✔ ✔ - ✔ - ✔ -
MODEL_THAI
Builder.
South Asian - ✔ - - - - - ✔ ✔ - ✔ ✔ - ✔ - ✔ -
MODEL_SOUTHASIA
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
If you are initializing the command buffer for the TM-T88V ANK model:
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
62
Chapter 4 API Reference
clearCommandBuffer
Clears command buffers used by APIs of the Builder class.
The command buffers stored in the Builder class instance will be retained until this API is executed.
Syntax
public void clearCommandBuffer()
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
///Process///
builder.clearCommandBuffer();
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
63
addTextAlign
Adds the text alignment setting to the command buffer.
Syntax
public void addTextAlign(int align) throws EposException
Parameter
align : Specifies the text alignment.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addTextAlign(Builder.ALIGN_CENTER);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
64
Chapter 4 API Reference
addTextLineSpace
Adds the line feed space setting to the command buffer.
Syntax
public void addTextLineSpace(int linespc)
throws EposException
Parameter
linespc : Specifies the line feed space (in dots). Specifies an integer from 0 to 255.
(Default value: Refer to Support Information by Printer (p.178).)
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
4
builder.addTextLineSpace(30);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
65
addTextRotate
Adds the text rotation setting to the command buffer.
Syntax
public void addTextRotate(int rotate)
throws EposException
Parameter
rotate : Specifies whether to rotate text.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addTextRotate(Builder.TRUE);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
66
Chapter 4 API Reference
addText
Adds the printing of text to the command buffer.
After printing text, to print content other than text, execute line feed or paper feed.
(Example: After printing text, an attempt was made to perform graphic printing, but nothing was
printed.)
Syntax
public void addText(String data) throws EposException
Parameter
data : Specify a character string to be printed.
For the horizontal tab/line feed, use the following escape sequences:
String Description
\t Horizontal tab(HT)
\n Line feed (LF)
\\ Carriage return
Exceptions
When processing fails, EposException is thrown with one of the following error values.
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addText("Hello,\t");
builder.addText("World!\n");
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
67
addTextLang
Adds the language setting to a command buffer. Encodes the string specified by addText (p.67) according
to the language information specified by this API.
Specify the value according to the language specifications set for Builder class (Constructor) (p.59).
Syntax
public void addTextLang(int lang) throws EposException
Parameter
lang : Specifies the target language.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addTextLang(Builder.LANG_EN);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
68
Chapter 4 API Reference
addTextFont
Adds the text font setting to the command buffer.
Syntax
public void addTextFont(int font) throws EposException
Parameter
font : Specifies the font.
TM printer-separate setting
TM-P60/TM-P60II
TM-T20/TM-T20II
TM-T70/TM-T70II
TM-T82/TM-T82II
TM-U220
TM-U330
TM-T88V
TM-T81II
TM-T83II
TM-T90II
TM-m10
TM-P20
TM-P80
Set value Description
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addTextFont(Builder.FONT_B);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
69
addTextSmooth
Adds the smoothing setting to the command buffer.
Syntax
public void addTextSmooth(int smooth)
throws EposException
Parameter
smooth : Specifies whether to enable smoothing.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
To enable smoothing:
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addTextSmooth(Builder.TRUE);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
70
Chapter 4 API Reference
addTextDouble
Adds the double-sized text setting to the command buffer.
Syntax
public void addTextDouble(int dw, int dh)
throws EposException
Parameter
dw : Specifies the double-sized width.
When Builder.TRUE or 1 is set for both the dw and dh parameters, double width and height
characters are printed.
Exceptions 4
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addTextDouble(Builder.TRUE, Builder.TRUE);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
71
addTextSize
Adds the text scale setting to the command buffer.
Syntax
public void addTextSize(int width, int height)
throws EposException
Parameter
width : Specifies the horizontal scale of text.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addTextSize(4, 4);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
72
Chapter 4 API Reference
addTextStyle
Adds the text style setting to the command buffer.
Syntax
public void addTextStyle(int reverse, int ul, int em
, int color) throws EposException
Parameter
reverse : Specifies inversion of black and white for text.
Builder.TRUE
Set value Description
Specifies emphasized printing of characters.
4
Builder.FALSE (default) Cancels emphasized printing of characters.
Builder.PARAM_UNSPECIFIED Retains the current setting.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
73
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addTextStyle(Builder.PARAM_UNSPECIFIED, Builder.TRUE,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
74
Chapter 4 API Reference
addTextPosition
Adds the horizontal print start position of text to the command buffer.
After executing this API, you cannot use addTextAlign (p.64) or addTextRotate (p.66).
Syntax
public void addTextPosition(int x) throws EposException
Parameter
x: Specifies the horizontal print start position (in dots).
Specifies an integer from 0 to 65535.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
To set the print position at 120 dots from the left end:
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addTextPosition(120);
4
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
75
addFeedUnit
Adds paper feeding in dots to the command buffer.
Syntax
public void addFeedUnit(int unit) throws EposException
Parameter
unit : Specifies the paper feed space (in dots). Specifies an integer from 0 to 255.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addFeedUnit(30);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
76
Chapter 4 API Reference
addFeedLine
Adds paper feeding in lines to the command buffer.
Syntax
public void addFeedLine(int line) throws EposException
Parameter
unit : Specifies the paper feed space (in lines). Specifies an integer from 0 to 255.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addFeedLine(3);
///Process///
} catch (EposException e) {
4
int errStatus = e.getErrorStatus();
}
77
addImage
Adds raster image printing to the command buffer.
Prints the graphic in the android.graphics.Bitmap class.
Out of the android.graphics.Bitmap class graphics, the specified scope is converted to raster image data
according to this API setting. 1 pixel of the image corresponds to 1 dot of the printer. If transparent shading
is included, it is regarded as white.
Syntax
public void addImage(Bitmap data, int x, int y
, int width, int height, int color
, int mode, int halftone
, double brightness, int compress)
throws EposException
Parameter
data : Specifies an instance of the android.graphics.Bitmap class.
x: Specifies the horizontal start position in the print area. Specifies an integer from 0 to
65534.
y: Specifies the vertical start position in the print area. Specifies an integer from 0 to 65534.
width : Specifies the width of the print area. Specifies an integer from 1 to 65535.
height : Specifies the height of the print area. Specifies an integer from 1 to 65535.
If the area specified by the x/y parameters and the width/height parameters extends beyond the
image size specified by the data parameter, an EposException with ERR_PARAM contained in its
error status occurs.
78
Chapter 4 API Reference
TM printer-separate setting
TM-U220/TM-U330
TM-P60/TM-P60II
TM-T20/TM-T20II
TM-T82/TM-T82II
TM-T88V
TM-T70II
TM-T81II
TM-T83II
TM-T90II
TM-m10
TM-P20
TM-P80
TM-T70
Set value Description
Monochrome
Builder.MODE_MONO ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
(2 tone)
Multiple tone
Builder.MODE_GRAY16 ✔ - - - - - ✔ - - - ✔ ✔ -
(16 tone)
Specify the half tone
Builder.PARAM_DEFAULT treatment method. ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
(Monochrome (2 tone))
Builder.PARAM_DEFAULT
(This is suitable for printing of characters).
Default value (dither) selection
4
In the case of multiple tone (16 tone), this is disregarded.
If you specify a value other than 1.0, the printing speed will become slower.
79
compress : Specifies image compression.
Specify Builder.COMPRESS_DEFLATE only when Bluetooth is selected for the interface.
TM printer-separate setting
TM-U220/TM-U330
TM-P60/TM-P60II
TM-T82/TM-T82II
TM-T20II
TM-T88V
TM-T70II
TM-T81II
TM-T83II
TM-T90II
TM-m10
TM-P20
TM-P80
TM-T20
TM-T70
Set value Description
Image compression is
Builder.COMPRESS_DEFLATE ✔ ✔ - - - ✔ - ✔ - - - ✔ - -
carried out
Image compression is
Builder.COMPRESS_NONE ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
not carried out
Specify the half tone
treatment method.
Builder.PARAM_DEFAULT ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
(Image compression
is not carried out)
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Bitmap imageData = null;
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
///Process///
builder.addImage(imageData, 0, 0, 256, 256, Builder.PARAM_DEFAULT,
Builder.MODE_MONO, Builder.HALFTONE_DITHER, 1.0,
Builder.PARAM_DEFAULT);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
80
Chapter 4 API Reference
• To print a raster image at high speed, specify Builder.ALIGN_LEFT for the addTextAlign (p.64),
and specify a multiple of 8 not exceeding the printer's paper width for the width parameter of
this API.
• When printing transmission images, the printing speed may become slower.
• Multiple tone printing is not supported in Page Mode. Multiple tone graphic printing is supported
in Standard Mode only.
Syntax
public void addImage(Bitmap data, int x, int y
, int width, int height, int color
, int mode, int halftone
, double brightness)
throws EposException
Parameter
data : Specifies an instance of the android.graphics.Bitmap class.
x: Specifies the horizontal start position in the print area. Specifies an integer from 0 to
65534.
4
y: Specifies the vertical start position in the print area. Specifies an integer from 0 to 65534.
width : Specifies the width of the print area. Specifies an integer from 1 to 65535.
height : Specifies the height of the print area. Specifies an integer from 1 to 65535.
If the area specified by the x/y parameters and the width/height parameters extends beyond the
image size specified by the data parameter, an EposException with ERR_PARAM contained in its
error status occurs.
81
mode : Specify the color mode.
TM printer-separate setting
TM-U220/TM-U330
TM-P60/TM-P60II
TM-T20/TM-T20II
TM-T82/TM-T82II
TM-T88V
TM-T70II
TM-T81II
TM-T83II
TM-T90II
TM-m10
TM-P20
TM-P80
TM-T70
Set value Description
Monochrome
Builder.MODE_MONO ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
(2 tone)
Multiple tone
Builder.MODE_GRAY16 ✔ - - - - - ✔ - - - ✔ ✔ -
(16 tone)
Specify the half tone
Builder.PARAM_DEFAULT treatment method. ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
(Monochrome (2 tone))
If you specify a value other than 1.0, the printing speed will become slower.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
82
Chapter 4 API Reference
Example
try {
Bitmap imageData = null;
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
///Process///
builder.addImage(imageData, 0, 0, 256, 256, Builder.PARAM_DEFAULT,
Builder.MODE_MONO, Builder.HALFTONE_DITHER, 1.0);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
To print an image 256 dots wide and 256 dots high in page mode:
try {
Bitmap imageData = null;
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
///Process///
builder.addPageBegin();
builder.addPagePosition(0, 255);
builder.addImage(imageData, 0, 0, 256, 256, Builder.PARAM_DEFAULT,
Builder.MODE_MONO, Builder.HALFTONE_DITHER, 1.0);
builder.addPageEnd();
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
83
addImage (Previous format)
Adds raster image printing to the command buffer. Multiple tones cannot be printed.
When a Bluetooth device is connected, white streaks may appear because printing by image data
compression is not possible.
Prints the graphic in the android.graphics.Bitmap class.
Of the graphics in the android.graphics.Bitmap class, makes the specified range into binary with the dither
processing, and converts it into raster image data. 1 pixel of the image corresponds to 1 dot of the printer. If
transparent shading is included, it is regarded as white.
Syntax
public void addImage(Bitmap data, int x, int y
, int width, int height, int color)
throws EposException
Parameter
data : Specifies an instance of the android.graphics.Bitmap class.
x: Specifies the horizontal start position in the print area. Specifies an integer from 0 to
65534.
y: Specifies the vertical start position in the print area. Specifies an integer from 0 to 65534.
width : Specifies the width of the print area. Specifies an integer from 1 to 65535.
height : Specifies the height of the print area. Specifies an integer from 1 to 65535.
color : Specifies the color.
If the area specified by the x/y parameters and the width/height parameters extends beyond the
image size specified by the data parameter, an EposException with ERR_PARAM contained in its
error status occurs.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
84
Chapter 4 API Reference
Example
try {
Bitmap imageData = null;
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
///Process///
builder.addImage(imageData, 0, 0, 256, 256, Builder.PARAM_DEFAULT);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
To print an image 256 dots wide and 256 dots high in page mode:
try {
Bitmap imageData = null;
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
///Process///
builder.addPageBegin();
builder.addPagePosition(0, 255);
builder.addImage(imageData, 0, 0, 256, 256, Builder.PARAM_DEFAULT);
builder.addPageEnd();
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
85
addLogo
Adds NV logo printing to the command buffer.
Prints a logo registered in the NV memory of the printer.
• Register a logo in advance into the printer using the following utilities:
Model-dedicated Utility
TM Flash Logo Setup Utility
• Multiple tone printing is not supported in Page Mode. Multiple tone graphic printing is supported
in Standard Mode only.
Syntax
public void addLogo(int key1, int key2)
throws EposException
Parameter
key1 : Specifies the key code 1 of an NV logo. Specifies an integer from 0 to 255.
key2 : Specifies the key code 2 of an NV logo. Specifies an integer from 0 to 255.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
To print a NV logo with the key code parameters specified as 48, 48:
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addLogo(48, 48);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
86
Chapter 4 API Reference
addBarcode
Adds barcode printing to the command buffer.
Syntax
public void addBarcode
(String data, int type, int hri, int font, int width
, int height) throws EposException
Parameter
data : Specifies the barcode data as a string.
Specify a string that follows the barcode standard specified by the type parameter. If the specified
string does not conform to the standard, a barcode will not be printed.
EAN13
facturer code. Specify 0s in empty digits.
When an 11-digit number is specified, a check digit is auto-
4
matically added.
JAN13 When a 12-digit number is specified, the 12th digit is pro-
cessed as a check digit but the check digit is not validated.
EAN8 When a 7-digit number is specified, a check digit is auto-
matically added.
JAN8 When an 8-digit number is specified, the 8th digit is pro-
cessed as a check digit but the check digit is not validated.
When the first character is *, the character is processed as
CODE39 the start character. In other cases, a start character is auto-
matically added.
Start and stop codes are automatically added.
ITF
Check digits are not added or validated.
Specify a start character (A to D, a to d).
CODABAR Specify a stop character (A to D, a to d).
Check digits are not added or validated.
Start and stop characters are automatically added.
CODE93
A check digit is automatically calculated and added.
87
Barcode type Description
Specify a start character (CODE A, CODE B, CODE C).
A stop character is automatically added.
A check digit is automatically calculated and added.
To encode each of the following characters, specify two
characters starting with the character "{":
FNC1: {1
FNC2: {2
CODE128
FNC3: {3
FNC4: {4
CODE A: {A
CODE B: {B
CODE C: {C
SHIFT: {S
{: {{
A start character, a check digit, and a stop character are
automatically added.
FNC1 is automatically added to the start of the data. It is
not added half way through the data.
To automatically calculate and add a check digit for an
application identifier (AI) and the subsequent data, specify
the character "*" in the position of the check digit.
You can enclose an application identifier (AI) in
parentheses. The parentheses are used as HRI print
characters and are not encoded as data.
GS1-128 You can insert spaces between an application identifier
(AI) and data. The spaces are used as HRI print characters
and are not encoded as data.
To encode each of the following characters, specify two
characters starting with the character "{":
FNC1: {1
FNC3: {3
(: {(
): {)
*: {*
{: {{
GS1 DataBar Omnidi-
rectional Specify a 13-digit global trade item number (GTIN) not
GS1 DataBar Truncated including an application identifier (AI) or a check digit.
GS1 DataBar Limited
88
Chapter 4 API Reference
To specify binary data that cannot be represented by character strings, use the
following escape sequences.
String Description
\xnn Control code
\\ Back slash
89
font : Specifies the HRI font.
width : Specifies the width of each module in dots. Specifies an integer from 2 to 6.
height : Specifies the barcode height in dots. Specifies an integer from 1 to 255.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
90
Chapter 4 API Reference
Example
To print barcodes:
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addBarcode("01234567890", Builder.BARCODE_UPC_A,
Builder.HRI_BELOW, Builder.PARAM_UNSPECIFIED, 2, 64);
builder.addBarcode("01234500005", Builder.BARCODE_UPC_E,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addBarcode("201234567890", Builder.BARCODE_EAN13,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addBarcode("201234567890", Builder.BARCODE_JAN13,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addBarcode("2012345", Builder.BARCODE_EAN8,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addBarcode("2012345", Builder.BARCODE_JAN8,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addBarcode("ABCDE", Builder.BARCODE_CODE39,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addBarcode("012345", Builder.BARCODE_ITF,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addBarcode("A012345A", Builder.BARCODE_CODABAR,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addBarcode("ABCDE", Builder.BARCODE_CODE93,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addBarcode("{Babcde", Builder.BARCODE_CODE128,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
4
builder.addBarcode("(01)201234567890*", Builder.BARCODE_GS1_128,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addBarcode("0201234567890",
Builder.BARCODE_GS1_DATABAR_OMNIDIRECTIONAL,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addBarcode("0201234567890",
Builder.BARCODE_GS1_DATABAR_TRUNCATED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addBarcode("0201234567890",
Builder.BARCODE_GS1_DATABAR_LIMITED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED);
builder.addBarcode("(01)2012345678903",
Builder.BARCODE_GS1_DATABAR_EXPANDED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
91
addSymbol
Adds 2D-Code printing to the command buffer.
Syntax
public void addSymbol
(String data, int type, int level, int width,
int height, int size)
throws EposException
Parameter
data : Specifies 2D-Code data as a character string.
92
Chapter 4 API Reference
93
2D-Code type Description
DataMatrix square After converting the character string to UTF-8,
DataMatrix rectangle, 8 lines conduct the escape sequence and encode.
DataMatrix rectangle, 12 lines The symbol is either a square ranging in size from
10 lines x 10 rows to 144 lines x 144 rows, or a
rectangle comprising 8 lines, 12 lines or 16 lines.
DataMatrix rectangle, 16 lines Up to 2,335 alphanumerical, 3,116 numerical fig-
ures and 1,556 bytes of binary data can be
specified.
To specify binary data that cannot be represented by character strings, use the
following escape sequences.
String Description
\xnn Control code
\\ Back slash
94
Chapter 4 API Reference
Set value
Integer from 0 to 255 Module width
Description
4
Builder.PARAM_UNSPECIFIED Retains the current setting.
MaxiCode is ignored.
95
size : Specifies the 2D-Code maximum size.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
To print 2D-Code:
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addSymbol("ABCDE", Builder.SYMBOL_PDF417_STANDARD,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addSymbol("ABCDE", Builder.SYMBOL_QRCODE_MODEL_2,
Builder.LEVEL_Q, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addSymbol("908063840\\x1d850\\x1d001\\x1d\\x04",
Builder.SYMBOL_MAXICODE_MODE_2, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED);
builder.addSymbol("0201234567890", Builder.SYMBOL_GS1_DATABAR_STACKED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addSymbol("0201234567890",
Builder.SYMBOL_GS1_DATABAR_STACKED_OMNIDIRECTIONAL,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
builder.addSymbol("(01)02012345678903",
Builder.SYMBOL_GS1_DATABAR_EXPANDED_STACKED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED,
Builder.PARAM_UNSPECIFIED, Builder.PARAM_UNSPECIFIED);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
96
Chapter 4 API Reference
addPageBegin
Adds the switching to page mode to the command buffer. The page mode process starts.
Syntax
public void addPageBegin() throws EposException
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addPageBegin();
builder.addText("ABCDE");
builder.addPageEnd();
///Process///
} catch (EposException e) {
}
int errStatus = e.getErrorStatus(); 4
97
addPageEnd
Adds the end of page mode to the command buffer. The page mode process ends.
Syntax
public void addPageEnd() throws EposException
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addPageBegin();
builder.addText("ABCDE");
builder.addPageEnd();
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
98
Chapter 4 API Reference
addPageArea
Adds the print area in page mode to the command buffer.
Specifies the print area in page mode (coordinates). After this API function, specify a print data API function
such as the addText method.
• Specify a print area to cover the content to be printed. If the print data extends beyond the print
area, the print result will be such that the print data has been printed incompletely.
• Use this API function by inserting it between addPageBegin (p.97) and addPageEnd (p.98).
Syntax
public void addPageArea(int x, int y, int width,
int height) throws EposException
Parameter
x: Specifies the origin of the horizontal axis (in dots). Specifies an integer from 0 to 65535. 0
is the left end of the printer's printable area.
y: Specifies the origin of the vertical axis (in dots). Specifies an integer from 0 to 65535. 0 is
the position in which no paper feed has been performed.
width : Specifies the width of the print area (in dots). Specifies an integer from 0 to 65535.
height : Specifies the height of the print area (in dots). Specifies an integer from 0 to 65535.
Determine the width and height of the print area according to the print direction setting. Otherwise,
the print data might not be printed completely.
Exceptions
4
When processing fails, EposException is thrown with one of the following error values.
Example
To specify the print area with the origin (100, 50), a width of 200 dots, and a height of 30 dots and print
the characters "ABCDE":
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addPageBegin();
builder.addPageArea(100, 50, 200, 30);
builder.addText("ABCDE");
builder.addPageEnd();
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
99
addPageDirection
Adds the page mode print direction setting to the command buffer. Specifies the print direction in page
mode. This function can be omitted if rotation is not required.
Use this API function by inserting it between addPageBegin (p.97) and addPageEnd (p.98).
Syntax
public void addPageDirection(int dir)
throws EposException
Parameter
dir : Specifies the print direction in page mode.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
100
Chapter 4 API Reference
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addPageBegin();
builder.addPageArea(100, 50, 30, 200);
builder.addPageDirection(Builder.DIRECTION_TOP_TO_BOTTOM);
builder.addText("ABCDE");
builder.addPageEnd();
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
101
addPagePosition
Adds the page mode print-position-set area to the command buffer.
Specifies the print start position (coordinates) in the area specified by the addPageArea method.
Use this API function by inserting it between addPageBegin (p.97) and addPageEnd (p.98).
Syntax
public void addPagePosition(int x, int y)
throws EposException
Parameter
x: Specifies the horizontal print position (in dots). Specifies an integer from 0 to 65535.
y: Specifies the vertical print position (in dots). Specifies an integer from 0 to 65535.
Specify the print start position (coordinates) according to the content to be printed. Refer to the
following.
To print a character string:
Specify the left end of the baseline for the first character. This can be omitted for left-aligned
printing of standard-sized characters. To print double-sized height characters, specify a value
equal to or greater than 42 for y.
To print a barcode:
Specify the bottom left of the symbol. And specify the barcode height for y.
To print a graphic/logo:
Specify the bottom left of the graphic data. And specify the graphic data height for y.
To print a 2D-Code:
Specify the top left of the symbol. This can be omitted when printing from the top left.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
To specify (50,30) for the print start position in the area specified by the addPageArea method and
print the characters "ABCDE":
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addPageBegin();
builder.addPageArea(100, 50, 200, 100);
builder.addPagePosition(50, 30);
builder.addText("ABCDE");
builder.addPageEnd();
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
102
Chapter 4 API Reference
addPageLine
Adds line drawing in page mode to the command buffer. Draws a line in page mode.
Syntax
public void addPageLine
(int x1, int y1, int x2, int y2, int style)
throws EposException
Parameter
x1: Specifies the horizontal start position of the line (in dots).
Specifies an integer from 0 to 65535.
y1: Specifies the vertical start position of the line (in dots).
Specifies an integer from 0 to 65535.
x2 : Specifies the horizontal end position of the line (in dots).
Specifies an integer from 0 to 65535.
y2 : Specifies the vertical end position of the line (in dots).
Specifies an integer from 0 to 65535.
style : Specifies the line type.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
103
Example
To draw a thin solid line between the start position (100, 0) and the end position (500, 0):
try {
Builder builder = new Builder("TM-P60", Builder.MODEL_ANK);
builder.addPageBegin();
builder.addPageLine(100, 0, 500, 0, Builder.LINE_THIN);
builder.addPageEnd();
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
104
Chapter 4 API Reference
addPageRectangle
Adds rectangle drawing in page mode to the command buffer. Draws a rectangle in page mode.
Use this API function by inserting it between addPageBegin (p.97) and addPageEnd (p.98).
Syntax
public void addPageRectangle
(int x1, int y1, int x2, int y2, int style)
throws EposException
Parameter
x1: Specifies the horizontal start position of the line (in dots).
Specifies an integer from 0 to 65535.
y1: Specifies the vertical start position of the line (in dots).
Specifies an integer from 0 to 65535.
x2 : Specifies the horizontal end position of the line (in dots).
Specifies an integer from 0 to 65535.
y2 : Specifies the vertical end position of the line (in dots).
Specifies an integer from 0 to 65535.
style : Specifies the line type.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
105
Example
To draw a rectangle with a thin solid line, with the start position (100, 0) and the end position (500, 200)
as its vertexes:
try {
Builder builder = new Builder("TM-P60", Builder.MODEL_ANK);
builder.addPageBegin();
builder.addPageRectangle(100, 0, 500, 200, Builder.LINE_THIN);
builder.addPageEnd();
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
106
Chapter 4 API Reference
addCut
Adds paper cut to the command buffer. Sets paper cut.
Syntax
public void addCut(int type) throws EposException
Parameter
type : Specifies the paper cut type.
Exceptions
When processing fails, EposException is thrown with one of the following error values. 4
Error status Description
ERR_PARAM Invalid parameter was passed.
ERR_MEMORY Could not allocate memory.
ERR_FAILURE An unspecified error occurred.
Example
To perform feed cut operation:
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addCut(Builder.CUT_FEED);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
107
addPulse
Adds the drawer kick to the command buffer. Sets the drawer kick.
Syntax
public void addPulse(int drawer, int time)
throws EposException
Parameter
drawer : Specifies the drawer kick connector.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
To send a 100 msec pulse signal to the pin 2 of the drawer kick connector:
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addPulse(Builder.DRAWER_1, Builder.PULSE_100);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
108
Chapter 4 API Reference
addSound
Adds the turning on of the buzzer to the command buffer. Sets the buzzer.
Syntax
public void addSound(int pattern, int repeat, int cycle)
throws EposException
Parameter
pattern : Specifies the buzzer pattern.
109
cycle : This specifies the buzzer sounding cycle (in units of milliseconds).
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addSound(Builder.PATTERN_1, 3, 1000);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
110
Chapter 4 API Reference
• You cannot set the buzzer sounding cycle. If you want to optionally set the buzzer sounding
cycle (milliseconds), use addSound (p.109).
• Not available in page mode.
• The buzzer function and the drawer cannot be used together.
• This API function cannot be used if the printer is not provided with the buzzer.
Syntax
public void addSound(int pattern, int repeat)
throws EposException
Parameter
pattern : Specifies the buzzer pattern.
111
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addSound(Builder.PATTERN_A, 3);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
112
Chapter 4 API Reference
addFeedPosition
Adds label / black mark paper feeding to the command buffer.
Syntax
public void addFeedPosition(int position)
throws EposException
Parameter
position : Specifies the feed position.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
113
addLayout
Adds label / black mark paper layout information to the command buffer.
Syntax
public void addLayout(int type, int width, int height,
int marginTop, int marginBottom,
int offsetCut, int offsetLabel)
throws EposException
Parameter
type : Specifies the paper type.
width : Specifies paper width (in units of 0.1 mm). Specifies an integer from 1 to 10000.
height : Specifies the distance (in units of 0.1 mm) from the standard printing position to the next
standard printing position. Specifies an integer from 0 to 10000.
If "0" is specified, the distance from the standard printing position to the next standard
printing position is detected automatically.
marginTop : Specifies the distance (in units of 0.1 mm) from the standard printing position to the top
position. Specifies an integer from -9999 to 10000.
marginBottom :Specifies the distance (in units of 0.1 mm) from the standard eject position to the bot-
tom edge of the printable area. Specifies an integer from -9999 to 10000.
offsetCut : Specifies the distance (in units of 0.1 mm) from the standard eject position to the cut-
ting position. Specifies an integer from -9999 to 10000.
offsetLabel : Specifies the distance (in units of 0.1 mm) from the standard eject position to the bot-
tom edge of the label. Specifies an integer from 0 to 10000.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
114
Chapter 4 API Reference
Example
try {
Builder builder = new Builder("TM-P60II", Builder.MODEL_ANK);
builder.addLayout(Builder.PAPER_TYPE_LABEL_BM, 600, 0,
15, -15, 15, 0);
///Process///
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
Detailed description
❏ See below for the parameters that can be specified for each type of paper, and the positions for those
parameters.
<Black Mark>
A A
Top position
CE
Cut
Receipt B
C Cut
A
C
4
Top position Top position
Bottom edge
of label
Set value
Mark Parameter Receipt Label
Receipt Label
(Black mark) (Black mark)
A width 1 to 10000 1 to 10000 1 to 10000 1 to 10000
B height 0 0 to 10000 0 to 10000 0 to 10000
C marginTop 0 -9999 to 10000 0 to 10000 -9999 to 10000
D marginBottom 0 0 -9999 to 0 -9999 to 10000
E offsetCut 0 -9999 to 10000 0 to 10000 0 to 10000
F offsetLabel 0 0 0 0 to 10000
115
addCommand
Adds commands to the command buffer. Sends ESC/POS commands.
Syntax
public void addCommand(byte[] data) throws EposException
Parameter
data : Specifies ESC/POS command as a binary data.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
byte[] data = null;
///Process///
builder.addCommand(data);
} catch (EposException e) {
int errStatus = e.getErrorStatus();
}
116
Chapter 4 API Reference
Syntax
public Print(Context context)
Parameter
context : Specifies the context of the application.
Example
import android.content.Context;
///Process///
117
Print class (Constructor)(Previous format)
Constructor for the Print class. Initializes a Print class instance.
The log output function cannot be used and communications via a USB connection cannot be made.
Use Print class (Constructor) (p.117) when using the log output function and when
communicating via a USB connection.
Syntax
public Print()
Example
///Process///
118
Chapter 4 API Reference
openPrinter
This starts communications with the printer and monitoring of printer status.
if communication with the printer is not required anymore, be sure to call closePrinter (p.126),
closePrinter API, to end communication with the printer.
Syntax
public void openPrinter
(int deviceType, String deviceName, int enabled,
int interval, int timeout) throws EposException
Parameter
deviceType : Specifies the type for the device to start communication.
deviceName : Specifies the identifier used for identification of the target device.
Specifies the following for each device type:
4
deviceType Specified Value
One of the following can be specified.
IPv4 IP address (Example: "192.168.192.168")
Print.DEVTYPE_TCP
MAC address (Example: "01:23:45:67:89:AB")
Printer host name (Arbitrary string)
Print.DEVTYPE_BLUETOOTH BD address (Example: "01:23:45:67:89:AB")
Print.DEVTYPE_USB Device node
119
enabled : This specifies whether printer status monitoring is enabled or disabled.
interval : This specifies the interval (in units of milliseconds) for updating printer status.
timeout : This specifies the maximum waiting time (in milliseconds) for establishing communica-
tion with the printer.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
Case where printer status monitoring is enabled and communications are commenced using Wi-Fi/
Ethernet and a printer with an IP address of 192.168.192.168
120
Chapter 4 API Reference
if communication with the printer is not required anymore, be sure to call closePrinter (p.126),
closePrinter API, to end communication with the printer.
• The timeout time for this API cannot be set. If you want to set the timeout time for this API,
use openPrinter (p.119).
• Printer status is notified to the events registered in the print class.
For details, see Automatic Acquisition of Printer Status (p.43).
• If you want to stop monitoring of printer status, call closePrinter (p.126).
• If another application opened the printer, depending on the connection method, care should
be taken about the following:
TCP connection:
Retry this API for 15 seconds. After 15 seconds, ERR_OPEN will be returned.
Bluetooth connection:
When an attempt is made to start communication using this API, its result may not be
returned.
• If you use the printer from multiple mobile terminals, see the Cautions (p.206).
Syntax
public void openPrinter
(int deviceType, String deviceName, int enabled,
int interval) throws EposException
Parameter 4
deviceType : Specifies the type for the device to start communication.
121
deviceName : Specifies the identifier used for identification of the target device.
Specifies the following for each device type:
interval : This specifies the interval (in units of milliseconds) for updating printer status.
Exceptions
When processing fails, EposException is thrown with one of the following error values.
122
Chapter 4 API Reference
Example
Case where printer status monitoring is enabled and communications are commenced using Wi-Fi/
Ethernet and a printer with an IP address of 192.168.192.168
123
openPrinter (Previous format)
Starts communication with the printer.
Printer status cannot be acquired.
if communication with the printer is not required anymore, be sure to call closePrinter (p.126),
closePrinter API, to end communication with the printer.
• The timeout time for this API cannot be set. If you want to set the timeout time for this API,
use openPrinter (p.119).
• If you want to automatically acquire the printer status, use openPrinter (p.119).
• If another application opened the printer, depending on the connection method, care should
be taken about the following:
TCP connection:
Retry this API for 15 seconds. After 15 seconds, ERR_OPEN will be returned.
Bluetooth connection:
When an attempt is made to start communication using this API, its result may not be
returned.
• If you use the printer from multiple mobile terminals, see the Cautions (p.206).
Syntax
public void openPrinter
(int deviceType, String deviceName) throws EposException
Parameter
deviceType : Specifies the type for the device to start communication.
deviceName : Specifies the identifier used for identification of the target device.
Specifies the following for each device type:
124
Chapter 4 API Reference
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
To start communication via Wi-Fi/Ethernet with the printer whose IP address is "192.168.192.168":
125
closePrinter
This ends communications with the printer and monitoring of printer status.
Syntax
public void closePrinter() throws EposException
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
126
Chapter 4 API Reference
sendData
Sends a print document created using the Builder class.
• If you are using a Bluetooth connection, it may not be able to detect the offline status, and
timeout errors may occur.
• If you use the printer from multiple mobile terminals, see the Cautions (p.206).
Syntax
public void sendData
(Builder builder, int timeout, int[] status,
int[] battery) throws EposException
Parameter
builder : Specifies a Builder class instance. For details on the Builder class, refer to Builder class
(p.55).
timeout : Specifies the transmission/reception waiting timeout time.
Adjust the timeout time according to the specifications for the model, communication
interface, and transmission data size.
Specifies an integer in the range 0-600000 (in milliseconds).
status : The printer status when command transmission ended is set. A combination of printer
status settings is set. For details, refer to Printer Statuses and Actions to Take (p.51).
battery : The battery status when command transmission ended is set.
For details, refer to Support Information by Printer (p.178).
If an exception occurs, use getPrinterStatus (p.149) with exception handling to acquire the
printer status, and getBatteryStatus (p.150) for the battery status.
4
Exceptions
When processing fails, EposException is thrown with one of the following error values.
127
Example
To send a command to the printer by specifying 10 seconds for its timeout parameter:
try {
Builder builder = new Builder("TM-P60II", Builder.MODEL_ANK);
builder.addText("ABCDE");
printer.openPrinter(Print.DEVTYPE_TCP, "192.168.192.168");
printer.sendData(builder, 10000, status, battery);
printer.closePrinter();
} catch (EposException e) {
int errStatus = e.getErrorStatus();
status[0] = e.getPrinterStatus();
battery[0] = e.getBatteryStatus();
}
128
Chapter 4 API Reference
• If you want to acquire the battery status when sending a print document, use sendData
(p.127).
• The battery status cannot be acquired. If you are using a Bluetooth connection, it may not be
able to detect the offline status, and timeout errors may occur.
• If you use the printer from multiple mobile terminals, see the Cautions (p.206).
Syntax
public void sendData
(Builder builder, int timeout, int[] status)
throws EposException
Parameter
builder : Specifies a Builder class instance. For details on the Builder class, refer to Builder class
(p.55).
timeout : Specifies the transmission/reception waiting timeout time.
Adjust the timeout time according to the specifications for the model, communication
interface, and transmission data size.
Specifies an integer in the range 0-600000 (in milliseconds).
status : The printer status when command transmission ended is set. A combination of printer
status settings is set. For details, refer to Printer Statuses and Actions to Take (p.51).
In an exception occurs, use the getPrinterStatus (p.149) with exception processing to get the
printer status.
4
Exceptions
When processing fails, EposException is thrown with one of the following error values.
129
Example
To send a command to the printer by specifying 10 seconds for its timeout parameter:
try {
Builder builder = new Builder("TM-T88V", Builder.MODEL_ANK);
builder.addText("ABCDE");
printer.openPrinter(Print.DEVTYPE_TCP, "192.168.192.168");
printer.sendData(builder, 10000, status);
printer.closePrinter();
} catch (EposException e) {
int errStatus = e.getErrorStatus();
status[0] = e.getPrinterStatus();
}
130
Chapter 4 API Reference
beginTransaction
Starts transaction.
Transaction indicates a set of print processing operations, such as printing a sheet of receipt or a coupon.
The operation from just after calling this API to when the transaction finishes using endTransaction (p.132)is
handled as one set of print processing operations.
For details about specifying a transaction, see the To specify a transaction (p.208).
Syntax
public void beginTransaction() throws EposException
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
// For printerModel and lang, specify the model you are using.
4
Builder builder = new Builder(printerModel, lang);
Builder builder2 = new Builder(printerModel, lang);
builder.addText("ABCDE");
builder2.addText("12345");
builder2.addCut(Builder.CUT_FEED);
printer.endTransaction();
printer.closePrinter();
} catch (EposException e) {
int errStatus = e.getErrorStatus();
status[0] = e.getPrinterStatus();
}
131
endTransaction
Finishes transaction.
Transaction indicates a set of print processing operations, such as printing a sheet of receipt or a coupon.
The operation from just after calling beginTransaction (p.131) to when the transaction finishes using this API is
handled as one set of print processing operations.
For details about specifying a transaction, see the To specify a transaction (p.208).
Syntax
public void endTransaction() throws EposException
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
try {
// For printerModel and lang, specify the model you are using.
Builder builder = new Builder(printerModel, lang);
Builder builder2 = new Builder(printerModel, lang);
builder.addText("ABCDE");
builder2.addText("12345");
builder2.addCut(Builder.CUT_FEED);
printer.endTransaction();
printer.closePrinter();
} catch (EposException e) {
int errStatus = e.getErrorStatus();
status[0] = e.getPrinterStatus();
}
132
Chapter 4 API Reference
setStatusChangeEventCallback
This registers the notification destination of printer status.
Syntax
public void setStatusChangeEventCallback
(StatusChangeEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface StatusChangeEventListener
extends EventListener
Listener Registration Method
void onStatusChangeEvent(String deviceName, int status)
Parameter
deviceName : The identifier (IPv4 type IP address/ BD address/ Device node/ Printer host name) of the
4
device that is notified of printer status is set.
status : Printer status is set.
Example
133
setOnlineEventCallback
This registers the notification destination of online events. This refers to events that are notified when printer
status is online.
Syntax
public void setOnlineEventCallback
(OnlineEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface OnlineEventListener extends
EventListener
Listener Registration Method
void onOnlineEvent(String deviceName)
Parameter
deviceName : The identifier (IPv4 type IP address/ BD address/ Device node/ Printer host name) of the
device that is notified of online event is set.
Example
134
Chapter 4 API Reference
setOfflineEventCallback
This registers the notification destination of offline events. This is the notification method when printer is offline
concerning printer status.
Syntax
public void setOfflineEventCallback
(OfflineEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface OfflineEventListener extends
EventListener
Listener Registration Method
void onOfflineEvent(String deviceName)
Parameter 4
deviceName : The identifier (IPv4 type IP address/ BD address/ Device node/ Printer host name) of the
device that is notified of offline event is set.
Example
135
setPowerOffEventCallback
This registers the notification destination of power off events. This refers to events that are notified when there
is no response concerning printer status.
Syntax
public void setPowerOffEventCallback
(PowerOffEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface PowerOffEventListener extends
EventListener
Listener Registration Method
void onPowerOffEvent(String deviceName)
Parameter
deviceName : The identifier (IPv4 type IP address/ BD address/ Device node/ Printer host name) of the
device that is notified of power off event is set.
Example
136
Chapter 4 API Reference
setCoverOkEventCallback
This registers the notification destination of cover close events. This refers to events that are notified when
printer status indicates cover close.
Syntax
public void setCoverOkEventCallback
(CoverOkEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface CoverOkEventListener extends
EventListener
Listener Registration Method
void onCoverOkEvent(String deviceName)
Parameter 4
deviceName : The identifier (IPv4 type IP address/ BD address/ Device node/ Printer host name) of the
device that is notified of cover close event is set.
Example
137
setCoverOpenEventCallback
This registers the notification destination of cover open events. This refers to events that are notified when
the cover is open concerning printer status.
Syntax
public void setCoverOpenEventCallback
(CoverOpenEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface CoverOpenEventListener extends
EventListener
Listener Registration Method
void onCoverOpenEvent(String deviceName)
Parameter
deviceName : The identifier (IPv4 type IP address/ BD address/ Device node/ Printer host name) of the
device that is notified of cover open event is set.
Example
138
Chapter 4 API Reference
setPaperOkEventCallback
This registers the notification destination of paper OK events. This refers to events that are notified when
printer status indicates paper OK.
Syntax
public void setPaperOkEventCallback
(PaperOkEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface PaperOkEventListener extends
EventListener
Listener Registration Method
void onPaperOkEvent(String deviceName)
Parameter 4
deviceName : The identifier (IPv4 type IP address/ BD address/ Device node/ Printer host name) of the
device that is notified of paper ok event is set.
Example
139
setPaperNearEndEventCallback
This registers the notification destination of paper near end events. This refers to events that are notified
when printer status indicates paper is near the end.
Syntax
public void setPaperNearEndEventCallback
(PaperNearEndEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface PaperNearEndEventListener extends
EventListener
Listener Registration Method
void onPaperNearEndEvent(String deviceName)
Parameter
deviceName : The identifier (IPv4 type IP address/ BD address/ Device node/ Printer host name) of the
device that is notified of paper near end event is set.
Example
140
Chapter 4 API Reference
setPaperEndEventCallback
This registers the notification destination of paper end events. This refers to events that are notified when
printer status indicates there is no paper.
Syntax
public void setPaperEndEventCallback
(PaperEndEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface PaperEndEventListener extends
EventListener
Listener Registration Method
void onPaperEndEvent(String deviceName)
Parameter 4
deviceName : The identifier (IPv4 type IP address/ BD address/ Device node/ Printer host name) of the
device that is notified of paper end event is set.
Example
141
setDrawerClosedEventCallback
This registers the notification destination of drawer closed events. This refers to events that are notified when
printer status indicates the drawer is closed.
Syntax
public void setDrawerClosedEventCallback
(DrawerClosedEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface DrawerClosedEventListener extends
EventListener
Listener Registration Method
void onDrawerClosedEvent(String deviceName)
Parameter
deviceName : The identifier (IPv4 type IP address/ BD address/ Device node/ Printer host name) of the
device that is notified of drawer closed event is set.
Example
142
Chapter 4 API Reference
setDrawerOpenEventCallback
This registers the notification destination of drawer open events. This refers to events that are notified when
printer status is drawer open.
Syntax
public void setDrawerOpenEventCallback
(DrawerOpenEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface DrawerOpenEventListener extends
EventListener
Listener Registration Method
void onDrawerOpenEvent(String deviceName)
Parameter 4
deviceName : The identifier (IPv4 type IP address/ BD address/ Device node/ Printer host name) of the
device that is notified of drawer open event is set.
Example
143
setBatteryLowEventCallback
This registers the notification destination of a battery low event. This refers to events that are notified when
printer status is battery offline.
Syntax
public void setBatteryLowEventCallback
(BatteryLowEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface BatteryLowEventListener extends
EventListener
Listener Registration Method
void onBatteryLowEvent(String deviceName)
Parameter
deviceName : The identifier (IPv4 format IP address / BD address/ Device node/ Printer host name) of
the device that performed battery low event notification is set.
Example
144
Chapter 4 API Reference
setBatteryOkEventCallback
This registers the notification destination of a battery OK event. This refers to events that are notified when
the printer status recovers from offline due to remaining battery power.
Syntax
public void setBatteryOkEventCallback
(BatteryOkEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface BatteryOkEventListener extends
EventListener
Listener Registration Method
void onBatteryOkEvent(String deviceName)
Parameter 4
deviceName : The identifier (IPv4 format IP address / BD address/ Device node/ Printer host name) of
the device that performed battery OK event notification is set.
Example
145
setBatteryStatusChangeEventCallback
This registers the notification destination of battery status.
Syntax
public void setBatteryStatusChangeEventCallback
(BatteryStatusChangeEventListener target)
Parameter
target : This specifies the object (listener interface) that has the notification destination method
(listener registration method). If null is specified for either the method or target, the noti-
fication destination registration is nullified.
Listener Interface
public interface BatteryStatusChangeEventListener
extends EventListener
Listener Registration Method
void onBatteryStatusChangeEvent
(String deviceName, int battery)
Parameter
deviceName : The identifier (IPv4 type IP address/ BD address/ Device node/ Printer host name) of the
device that is notified of battery status is set.
battery : Battery status is set.
Example
146
Chapter 4 API Reference
getStatus
Acquires the printer status and the battery status.
In addition to the printer statuses acquired by sendData (p.127), this API can acquire the following printer
statuses.
Head temporary overheat error
Motor driver IC temporary overheat error
Battery temporary overheat error
Paper error
Syntax
public void getStatus(int[] status, int[] battery)
throws EposException
Parameter
status : This sets the printer status at the time this API was executed.
A combination of printer status settings is set. For details, refer to Printer Statuses and
Actions to Take (p.51).
battery : This sets the battery status at the time this API was executed.
For details, refer to Support Information by Printer (p.178).
Exceptions
When processing fails, EposException is thrown with one of the following error values.
Example
147
getErrorStatus
Acquire the error status from an exception.
Syntax
public int getErrorStatus()
Return value
Returns the error status set by the API in which an exception occurred.
Example
try {
printer.openPrinter(Print.DEVTYPE_TCP, "192.168.192.168");
} catch (EposException e) {
int errStatus = e.getErrorStatus();
if (errStatus == EposException.ERR_OPEN) {
///Process///
}
}
148
Chapter 4 API Reference
getPrinterStatus
Acquires the printer status from an exception that occurred in sendData (p.127).
Syntax
public int getPrinterStatus()
Return value
Returns the printer status. A combination of printer status settings is set.
For details, refer to Printer Statuses and Actions to Take (p.51).
Example
try {
printer.sendData(builder, timeout, printerStatus);
} catch (EposException e) {
int errSratus = e.getErrorStatus();
if (errStatus == EposException.ERR_TIMEOUT) {
printerStatus[0] = e.getPrinterStatus();
}
}
}
///Process///
4
149
getBatteryStatus
Acquires the battery status from an exception that occurred in sendData (p.127).
Syntax
public int getBatteryStatus()
Return value
Returns the battery status. For details, refer to Support Information by Printer (p.178).
Example
try {
printer.sendData(builder, timeout, printerStatus, batteryStatus);
} catch (EposException e) {
int errSratus = e.getErrorStatus();
if (errStatus == EposException.ERR_TIMEOUT) {
printerStatus[0] = e.getPrinterStatus();
batteryStatus[0] = e.getBatteryStatus();
}
}
150
Chapter 4 API Reference
Finder class
Class to search for printers. The following APIs are available.
EpsonIoException class
This class notifies you of the exception error value that occurred during the API calling of the Finder class
and the EpsonIo class (p.171).
The following APIs are available.
151
start
Starts a search for printers of the specified device type.
If you use this API, be sure to use stop (p.153) to stop the search.
You cannot call this API when a printer search is already in progress.
Syntax
public static synchronized void start
(Context context, int deviceType,
String findOption)
throws EpsonIoException
Parameter
context : Set a Context class instance of caller.
(Example: Set the Context acquired by getBaseContext() in Activity.)
deviceType : Specifies the device type to search for. The following values can be specified.
deviceType Description
DevType.TCP Searches for TM devices connected to the network
Searches for Bluetooth devices that have a device class
DevType.BLUETOOTH
of Printer or Uncategorized.
Searches for USB devices from the PID and VID.
DevType.USB Search condition
Searches for TM device connected to the USB.
findOption : Specifies the setting value when searching for a specific target device.
Exceptions
When processing fails, EpsonIoException is thrown with one of the following error values.
152
Chapter 4 API Reference
stop
Stops the printer search.
Syntax
public static synchronized void stop()
throws EpsonIoException
Exceptions
When processing fails, EpsonIoException is thrown with one of the following error values.
153
getDeviceinfolist
Acquires the results of device search until this API is called.
This API cannot acquire Bluetooth devices or USB devices that are already open.
Syntax
public static synchronized final DeviceInfo[]
getDeviceInfoList(int filterOption)
throws EpsonIoException
Parameter
filterOption : This specifies the filtering method for Epson printers. Specify one of the following values:
For TCP or USB connection, only Epson printers are searched for regardless of the FitlerOption
setting.
Return value
The device information list (DeviceInfo[]) of devices found during search is returned.
Device information is stored in the list as a DeviceInfo-type array.
Information to be stored varies depending on the device type.
154
Chapter 4 API Reference
Exceptions
When processing fails, EpsonIoException is thrown with one of the following error values.
155
getResult (Previous format)
Gets the printer search result until the time when this API was called.
This API cannot acquire Bluetooth devices or USB devices that are already open.
Syntax
public static synchronized final String[] getResult()
throws EpsonIoException
Return value
The list of devices found during search is returned.
Identification information of the found devices is stored as a character string (String type) in the list.
The stored results differ depending on the type of device (deviceType).
Exceptions
When processing fails, EpsonIoException is thrown with one of the following error values.
156
Chapter 4 API Reference
getStatus
Gets the error value of the exception.
Syntax
public int getStatus();
Return value
Returns the error value that is thrown with the exception. Error values are defined in the IoStatus class.
157
Printer Easy Select API
The Printer Easy Select APIs are APIs for selecting a printer using NFC or QR Code. They convert data
obtained from NFC or QR code to a format that can be passed to openPrinter.
The following classes are available.
❏ EasySelect class (p. 158)
❏ EasySelectInfo class (p. 158)
EasySelect class
Analyzes NFC data and QR code data. The following APIs are available.
EasySelectInfo class
This class stores data analyzed by an EasySelect class instance and converts it into a variable to be passed
to openPrinter. The following member variables are available.
158
Chapter 4 API Reference
parseNFC
Analyzes NFC tag data.
Syntax
public ArrayList<EasySelectInfo>
parseNFC(Tag tag, int timeout);
Parameter
tag : Specifies NFC tag data.
Return value
Returns the result of NFC analysis. Stores it into an ArrayList<EasySelectInfo> class instance.
If analysis fails, returns null.
Among the EasySelectInfo members, null or "" will be specified to the information that could not be
obtained from tag. The causes and countermeasures are described below.
When EasySelectInfo.printerName is null or "" 4
The printer name is not included in NFC. Specify the printer name in advance or take any other
countermeasure.
When EasySelectInfo.macAddress is ""
In products that have both Ethernet and Wi-Fi interfaces, if the network communication is disabled or if
there is no response from the printer's macAddress within the specified timeout limit, the macAddress is
"". Check if the printer is turned on and if the network connection has been established.
159
parseNFC (Previous format)
Analyzes NFC tag data.
Not supported in products that have both Ethernet and Wi-Fi interfaces.
Syntax
public EasySelectInfo parseNFC(Tag tag)
Parameter
tag : Specifies NFC tag data.
Return value
Returns the result of NFC analysis. Stores it into an EasySelectInfo class instance.
If analysis fails, returns null.
Among the EasySelectInfo members, null or "" will be specified to the information that could not be
obtained from tag. The causes and countermeasures are described below.
When EasySelectInfo.printerName is null or ""
The printer name is not included in NFC. Specify the printer name in advance or take any other
countermeasure.
When EasySelectInfo.macAddress is ""
When using a product that has both Ethernet and Wi-Fi interfaces, the macAddress is "". Use parseNFC
(p.159)
parseQR
Analyzes QR code string data.
Syntax
public EasySelectInfo parseQR(String data)
Parameter
data : Specifies QR code string data.
Return value
Returns the result of QR code string data analysis. Stores it into an EasySelectInfo class instance.
If analysis fails, returns null.
160
Chapter 4 API Reference
createQR
Creates QR code print data for Easy Select.
Syntax
public String createQR(String printerName,
int deviceType,
String macAddress)
Parameter
printerName : Specifies the printer name.
deviceType : Specifies the device type. Set either of the following:
Format Description
00:11:22:33:44:55 Separated by a colon ";".
00-11-22-33-44-55 Separated by a hyphen "-".
001122334455 Not separated.
Return value
Returns QR code print data for Easy Select. If print data creation fails, returns null. 4
161
deviceType
Stores the device type in the analysis result.
Format
int deviceType;
printerName
Stores the printer name in the analysis result.
Format
String printerName;
macAddress
Stores the BD address in the analysis result.
Format
String macAddress;
162
Chapter 4 API Reference
Log class
Sets the log output function.
setLogSettings
Sets the log output function.
Syntax
public static void setLogSettings(Context context,
int period, int enabled, String ipAddress,
int port, int logSize, int logLevel)
throws EposException
Parameter
context : Specifies the context of the application.
period : Specifies the method of setting the log output function.
To specify period for the Log.LOG_PERMANENT, set the permissions for the application
to access the storage.
163
enabled : Specifies whether to enable the log output function and the log output destination.
• To specify enabled for the Log.LOG_STORAGE, set the permissions for the application
to access the storage.
• To specify enabled for the Log.LOG_TCP, set the permissions for the application to
access the network.
If either of the following values is specified for enabled, "null" can be specified for this
parameter.
Log.LOG_DISABLE
Log.LOG_STORAGE
port : Specifies the port number for TCP communication. Specifies an integer from 0 to 65535.
Even if either of the following values is specified for enabled, specify an integer within the
range.
Log.LOG_DISABLE
Log.LOG_STORAGE
logSize : Specifies the maximum size of log data that is saved on the device's storage. Specifies
an integer from 1 to 50 (Unit: MB).
Even if either of the following values is specified for enabled, specify an integer within the
range.
Log.LOG_DISABLE
Log.LOG_TCP
Exceptions
When processing fails, EposException is thrown with one of the following error values.
164
Chapter 4 API Reference
Example
To output log data to port 8080 (IP address: 192.168.192.168) over TCP:
try {
Log.setLogSettings(getApplicationContext(), Log.LOG_PERMANENT,
Log.LOG_TCP, "192.168.192.168", 8080, 10, Log.LOG_LOW);
} catch (EposException e) {
int errStatus = e.getErrorStatus();
status[0] = e.getPrinterStatus();
}
try {
Log.setLogSettings(getApplicationContext(), Log.LOG_PERMANENT,
Log.LOG_STORAGE, null, 0, 10, Log.LOG_LOW);
} catch (EposException e) {
int errStatus = e.getErrorStatus();
status[0] = e.getPrinterStatus();
}
try {
Log.setLogSettings(getApplicationContext(), Log.LOG_PERMANENT,
Log.LOG_DISABLE, null, 0, 10, Log.LOG_LOW);
} catch (EposException e) {
int errStatus = e.getErrorStatus();
status[0] = e.getPrinterStatus();
}
165
How to Extract a Log File
Save destination
File name
❏ EposLog.xx
Item Description
Date and time In yyyy/mm/dd,h:mm:ss.000 format.
Process ID: thread ID ID of each process
Layer at which data is input and output
Input and output layer APIIO: Interface layer called by the application
IOCM/DEVIO: Layer for communication with devices
Direction in which data is input and output
Input and output direction ->: Input from a layer
<-: Output from a layer
Input and output data Called API, parameter, and communication data
Output example
To call the addCut method from the application:
2014/07/28,20:12:35.836,00002ae9:00006008,APIIO,->,0x687bc5d8,,addCut,1
2014/07/28,20:12:35.836,00002ae9:00006008,APIIO,<-,0x687bc5d8,0,addCut}
166
Chapter 5 Command Transmission/Reception
Command Transmission/Reception
This chapter describes APIs for transmission and reception of commands (ESC/POS commands, etc.).
The APIs for command transmission and reception described in this chapter are intended for
customers who understand ESC/POS commands very well.
A command transmission/reception API cannot be used with the Print class (p.57) of ePOS-Print
API.
Programming
Programming Flow
Perform programming following this flow.
5
3. Opening a Device Port (p.168)
* This is optional.
167
Opening a Device Port
Use the EpsonIo class's open (p.171) to open a device port. Please refer to the following code.
////Wi-Fi/Ethernet device
mPort.open(DevType.TCP, "192.168.192.168", null, null);
////Bluetooth device
mPort.open(DevType.BLUETOOTH, "00:00:12:34:56:78", null, null);
////USB device
mPort.open(DevType.USB, "/dev/bus/usb/001/002", null, getApplicationContext());
//Exception handling
} catch ( EpsonIoException e ) {
errStatus = e.getStatus();
}
Sending Data
Use the EpsonIo class's write (p.175) to send data to the printer. Please refer to the following code.
try {
//Send data
sizeWritten = mPort.write(data, offset, size, timeout);
//Exception handling
} catch ( EpsonIoException e ) {
errStatus = e.getStatus();
}
168
Chapter 5 Command Transmission/Reception
Receiving Data
Use the EpsonIo class's read (p.176) to receive data from the printer. Please refer to the following code.
//Receive data
try {
sizeRead = mPort.read(data, offset, size, timeout);
//Exception handling
} catch ( EpsonIoException e ) {
errStatus = e.getStatus();
}
169
Exception handling
A command transmission/reception API generates a propriety exception with an integer (int) type
parameter when an error occurs and notify the calling side of such an error.
try {
sizeWritten = mPort.write(data, offset, size, timeout);
} catch ( EpsonIoException e ) {
//Get error value
errStatus = e.getStatus();
}
170
Chapter 5 Command Transmission/Reception
EpsonIo class
Class to transmit and receive data. The following APIs are available.
open
Opens the specified device port.
Syntax
public void open
(int deviceType, String deviceName,
String deviceSettings, Context context)
throws EpsonIoException
Parameter
deviceType : Specifies the device type to open. The following values can be specified.
DevType.BLUETOOTH
with Wi-Fi/Ethernet.
Specify this when the printer to be opened will connect
5
with Bluetooth.
DevType.USB Specify this when the printer to be opened will connect
with USB.
deviceName : Specifies the identifier to locate the target device. The following values can be speci-
fied.
deviceSettings :
Specify "null".
171
context : Specifies the context of the application.
Exceptions
When processing fails, EpsonIoException is thrown with one of the following error values.
172
Chapter 5 Command Transmission/Reception
open(Previous format)
Opens the specified device port.
Syntax
public void open
(int deviceType, String deviceName,
String deviceSettings)
throws EpsonIoException
Parameter
deviceType : Specifies the device type to open. The following values can be specified.
deviceType Description
DevType.TCP Specify this when the printer to be opened will connect
with Wi-Fi/Ethernet.
DevType.BLUETOOTH Specify this when the printer to be opened will connect
with Bluetooth.
deviceName : Specifies the identifier to locate the target device. The following values can be speci-
fied.
deviceSettings :
DevType.BLUETOOTH BD address (Example: "01:23:45:67:89:AB")
5
Specify "null".
Exceptions
When processing fails, EpsonIoException is thrown with one of the following error values.
173
close
Closes the specified device port.
Syntax
public void close() throws EpsonIoException
Exceptions
When processing fails, EpsonIoException is thrown with one of the following error values.
174
Chapter 5 Command Transmission/Reception
write
Sends data to a device port.
Syntax
public int write
(byte[] data, int offset, int size,
int timeout)
throws EpsonIoException
Parameter
data : The sending data buffer. It stores data to be sent.
offset : Specifies the start position for sending data.
Please specify the offset value from the top of the sending data buffer.
size : Specifies the number of bytes to send.
If "0" is specified for size, no data will be sent. In such a case, the return value will be "0".
• Take the transmission speed and volume of data to be sent into account when specifying
the timeout value.
• When the timeout value is too short, the sending process will still continue until all the
data has been sent, while normal data sending is occurring, even if the timeout value is
exceeded.
• With a Bluetooth device, there is a chance that the sending process will be blocked. In
such a case, processing will not complete even if the specified timeout value elapses.
Return value
Returns the number of bytes of data that were sent.
5
• The printer did not necessarily receive the amount of data that the return value shows.
• If the amount of time specified in timeout is exceeded, the returned return value is the number
of bytes that were sent up to that point.
Exceptions
When processing fails, EpsonIoException is thrown with one of the following error values.
175
read
Receives data from a device port.
This API continues receiving until a receiving error occurs. However, if not even a single byte of
data is received during the period specified in timeout, the process ends.
Syntax
public int read
(byte[] data, int offset, int size,
int timeout)
throws EpsonIoException
Parameter
data : The receiving data buffer for storing received data.
offset : Specifies the point to start storing data in the receiving data buffer.
Please specify the offset value from the top of the receiving data buffer.
size : Specifies the number of bytes that can be received.
If "0" is specified for size, no data will be received. In such a case, the return value will be
"0".
timeout : Specifies the time in milliseconds to receive data. The maximum value that can be
specified is 600000 (which equates to 10 minutes).
Return value
Returns the number of bytes that were received.
Exceptions
When processing fails, EpsonIoException is thrown with one of the following error values.
176
Appendix
Appendix
List of Supported APIs for Each Printer Model
TM-P60II[Peeler]
TM-P60[Peeler]
TM-U220
TM-U330
TM-P60II
TM-T88V
TM-T20II
TM-T70II
TM-T81II
TM-T82II
TM-T83II
TM-T90II
TM-m10
TM-P20
TM-P60
TM-P80
TM-T20
TM-T70
TM-T82
API
addTextAlign (p.64) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addTextLineSpace (p.65) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addTextRotate (p.66) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addText (p.67) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addTextLang (p.68) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addTextFont (p.69) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addTextSmooth (p.70) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ - -
addTextDouble (p.71) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ - -
addTextSize (p.72) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ - -
addTextStyle (p.73) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addTextPosition (p.75) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ - ✔
addFeedUnit (p.76) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addFeedLine (p.77) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addImage (p.78) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addImage (Previous format) (p.81) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addImage (Previous format) (p.84) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addLogo (p.86) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ - -
addBarcode (p.87) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ - -
addSymbol (p.92) ✔ ✔ - ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ - -
addPageBegin (p.97) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ - -
addPageEnd (p.98) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ - -
addPageArea (p.99) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ - -
addPageDirection (p.100) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ - -
addPagePosition (p.102) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ - -
addPageLine (p.103) ✔ ✔ - ✔ ✔ ✔ ✔ - - - - - - - - - - - -
addPageRectangle (p.105) ✔ ✔ - ✔ ✔ ✔ ✔ - - - - - - - - - - - -
addCut (p.107) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addPulse (p.108) ✔ - - - - - - ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
addSound (p.109) ✔ ✔ - - ✔ ✔ ✔ - ✔ - ✔ - ✔ ✔ ✔ ✔ - - ✔
addSound (Previous format) (p.111) ✔ ✔ - - ✔ ✔ ✔ - ✔ - ✔ - ✔ ✔ ✔ ✔ - - ✔
addFeedPosition (p.113) - ✔ - ✔ - ✔ ✔ - - - - - - - - - - - ✔
addLayout (p.114) - ✔ - ✔ - ✔ ✔ - - - - - - - - - - - -
addCommand (p.116) ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
177
Support Information by Printer
TM-m10
58 mm
Character Baseline Font A ANK; At the 21st dot from the top of the character
Kanji *: At the 21st dot from the top of the character
Font B ANK; At the 21st dot from the top of the character
Kanji *: At the 21st dot from the top of the character
178
Appendix
58 mm
179
TM-P20 (ANK model / Multi-language model)
58 mm
Character Baseline Font A ANK: At the 21st dot from the top of the character
Kanji *: At the 21st dot from the top of the character
180
Appendix
58 mm
Battery Supported
Battery Status
Upper 8 bits
Lower 8 bits
181
TM-P60
58 mm 60 mm
Character Baseline Font A At the 21st dot from the top of the character
Page Mode Default Area 420 dots x 1200 dots (W x H) 432 dots x 1200 dots (W x H)
Page Mode Maximum Area 420 dots x 1200 dots (W x H) 432 dots x 1200 dots (W x H)
Buzzer Supported
Battery Supported
182
Appendix
Battery Status
Upper 8 bits
Lower 8 bits
183
TM-P60II/ TM-P60II with Peeler (ANK model / Multi-language model)
Character Baseline Font A ANK: At the 21st dot from the top of the character
Kanji *: At the 21st dot from the top of the character
Page Mode Default Area 432 dots x 1624 dots (W x H) 400 dots x 1624 dots (W x H)
Page Mode Maximum Area 432 dots x 1624 dots (W x H) 400 dots x 1624 dots (W x H)
184
Appendix
Battery Supported
Paper Layout
Die-cut label Die-cut label
Receipt paper Receipt paper
paper paper
Paper type (without black (with black
(without black (with black
mark) mark)
mark) mark)
width (sf) 290 to 600 290 to 600 290 to 600 290 to 600
offsetLabel (sd) 0 0 0 0 to 15
Battery Status
Upper 8 bits
Lower 8 bits
185
TM-P80 (ANK model / Multi-language model)
80 mm
Character Baseline Font A ANK: At the 21st dot from the top of the character
Kanji *: At the 21st dot from the top of the character
Battery Supported
186
Appendix
Paper Layout
Receipt paper Receipt paper
Paper type
(without black mark) (with black mark)
marginBottom (se) 0 0
offsetLabel (sd) 0 0
Battery Status
Upper 8 bits
Lower 8 bits
187
TM-T20
58 mm 80 mm
Character Baseline Font A At the 21st dot from the top of the character
Page Mode Default Area 420 dots x 831 dots (W x H) 576 dots x 831 dots (W x H)
Page Mode Maximum Area 420 dots x 1662 dots (W x H) 576 dots x 1662 dots (W x H)
188
Appendix
TM-T20II
58 mm 80 mm
Character Font A At the 21st dot from the top of the character
Baseline
Font B At the 16th dot from the top of the character
Page Mode Default Area 420 dots x 831 dots (W x H) 576 dots x 831 dots (W x H)
Page Mode Maximum Area 420 dots x 1662 dots (W x H) 576 dots x 1662 dots (W x H)
189
TM-T70 (ANK model)
80 mm
Character Baseline Font A At the 21st dot from the top of the character
190
Appendix
80 mm
Character Baseline Font A ANK: At the 21st dot from the top of the character
Kanji: At the 21st dot from the top of the character
191
TM-T70II (ANK model)
80 mm
Character Baseline Font A At the 21st dot from the top of the character
192
Appendix
58 mm 80 mm
Character Font A ANK: At the 21st dot from the top of the character
Baseline Kanji *2: At the 21st dot from the top of the character
Font B ANK *1: At the 15th dot from the top of the character
ANK: At the 16th dot from the top of the character
Kanji *1: At the 15th dot from the top of the character
Special font A *2 At the 21st dot from the top of the character
Special font B *2 At the 21st dot from the top of the character
Page Mode Default Area 416 dots x 1662 dots (W x H) 576 dots x 1662 dots (W x H)
Page Mode Maximum Area 416 dots x 1662 dots (W x H) 576 dots x 1662 dots (W x H)
193
58 mm 80 mm
194
Appendix
TM-T81II
80 mm
Character Baseline Font A At the 21st dot from the top of the character
195
TM-T82
58 mm 80 mm
Character Baseline Font A At the 21st dot from the top of the character
Page Mode Default Area 420 dots x 831 dots (W x H) 576 dots x 831 dots (W x H)
Page Mode Maximum Area 420 dots x 1662 dots (W x H) 576 dots x 1662 dots (W x H)
Buzzer Optional
196
Appendix
80 mm
Character Font A ANK: At the 21st dot from the top of the character
Baseline Kanji *: At the 21st dot from the top of the character
197
80 mm
198
Appendix
TM-T83II
80 mm
Character Baseline Font A ANK: At the 21st dot from the top of the character
Kanji: At the 21st dot from the top of the character
Font B ANK: At the 16th dot from the top of the character
Kanji: At the 15th dot from the top of the character
199
TM-T88V (ANK model / Multi-language model)
58 mm 80 mm
Character Baseline Font A ANK: At the 21st dot from the top of the character
Kanji *: At the 21st dot from the top of the character
Font B ANK: At the 16th dot from the top of the character
Kanji *: At the 15th dot from the top of the character
Special font A* At the 20th dot from the top of the character
Special font B* At the 20th dot from the top of the character
Page Mode Default Area 360 dots x 831 dots (W x H) 512 dots x 831 dots (W x H)
Page Mode Maximum Area 360 dots x 1662 dots (W x H) 512 dots x 1662 dots (W x H)
200
Appendix
58 mm 80 mm
201
TM-T90II
58 mm 80 mm
Character Baseline Font A At the 21st dot from the top of the character
Page Mode Default Area 420 dots x 1662 dots (W x H) 576 dots x 1662 dots (W x H)
Page Mode Maximum Area 420 dots x 1662 dots (W x H) 576 dots x 1662 dots (W x H)
Buzzer Supported
202
Appendix
TM-U220
76 mm 69.5 mm 57.5 mm
Resolution Single-
80 dpi x 72 dpi (W x H)
density
Double
160 dpi x 72 dpi (W x H)
-density
Double
400 or 385*1 half dots 360 half dots 300 or 297*1 half dots
-density
203
*1: DipSW2-1 = ON
*2: Differs depending on the Multilingual Model specifications.
204
Appendix
TM-U330
76 mm 69.5 mm 57.5 mm
Resolution Single-
80 dpi x 72 dpi (W x H)
density
Double-
160 dpi x 72 dpi (W x H)
density
Print Width 120 dpi base 300 dots 270 dots 225 dots
Chinese
16 characters 15 characters 12 characters
(180/90 dpi)
Chinese
22 characters 20 characters 16 characters
(80 dpi)
Font B -
Chinese -
205
Cautions
ePOS-Print
Mobile terminal A (Printer) Mobile terminal B
1 : openPrinter
SUCCESS
3 : sendData
4 : sendData
Printing processing
Mobile terminal B
able to print
Printing processing
SUCCESS
6 : closePrinter
206
Appendix
ePOS-Print
Mobile terminal A (Printer) Mobile terminal B
1 : openPrinter
3 : sendData
5 : closePrinter
Printing processing
SUCCESS
6 : closePrinter
207
To specify a transaction
Put the set of print processing to be carried out consecutively (such as a single receipt or a single coupon)
between beginTransaction (p.131) and endTransaction (p.132).
Application ePOS-Print
1 : openPrinter
Transaction 2 : beginTransaction
3 : sendData
Printing processing
4 : sendData
Printing processing
5 : endTransaction
6 : closePrinter
208
Appendix
ZXing(https://github.com/zxing/zxing)
ZXing is licensed based on Apache 2.0 license (http://www.apache.org/licenses/LICENSE-2.0.html).
209
210