public class EscCommand extends Command
Command.CHARACTER_SET, Command.ENABLE, Command.FONT, Command.FOOT, Command.HEIGHT_ZOOM, Command.HRI_POSITION, Command.ImageAlgorithm, Command.JUSTIFICATION, Command.STATUS, Command.UNDERLINE_MODE, Command.WIDTH_ZOOM
mConnecter
Modifier and Type | Method and Description |
---|---|
boolean |
addArabicText(String text,
Command.JUSTIFICATION justification)
插入阿拉伯文字
|
boolean |
addBarcode(String content)
方法说明:打印CODABAR码
|
boolean |
addBlackMark(boolean isOpenBlackMark)
设置黑标模式
|
boolean |
addBlackMarkCutterPosition(int vertical)
设置黑标切纸位置
|
boolean |
addBlackMarkPagerLength(int length)
设置黑标长度
|
boolean |
addBlackMarkStartPrintPosition(int vertical)
设置黑标起始打印位置
|
boolean |
addBlackMarkWidth(int width)
设置黑标宽度
|
boolean |
addCancelKanjiMode()
设置汉字无效
|
boolean |
addCancelPrintData()
页模式取消打印数据。
|
boolean |
addCancelUserDefinedCharacters(byte n)
设置取消自定义字符
|
boolean |
addCODE128(String content)
打印CODE128码
|
boolean |
addCODE39(String content)
方法说明:打印UPCE条码
|
boolean |
addCODE93(String content)
打印CODE93码
|
boolean |
addCutAndFeedPaper(byte length)
设置切纸后走纸
|
boolean |
addCutPaper()
切纸
|
boolean |
addDownloadNvBitImage(android.graphics.Bitmap[] bitmap)
打印下载NV位图
|
boolean |
addEAN13(String content)
打印EAN13码
|
boolean |
addEAN8(String content)
打印EAN8码
|
boolean |
addGeneratePlus(Command.FOOT foot,
byte t1,
byte t2)
开钱箱
|
boolean |
addGeneratePluseAtRealtime(Command.FOOT foot,
byte t)
立即开启钱箱
|
boolean |
addHorTab()
插入水平跳格
|
boolean |
addInitializePrinter()
打印机初始化
|
boolean |
addITF(String content)
方法说明:打印ITF条码
|
boolean |
addOriginRastBitImage(android.graphics.Bitmap bitmap,
int nWidth,
int nMode) |
boolean |
addPageModeVerticalAbsolutePosition(int position)
设置页模式垂直方向绝对位置
|
boolean |
addPageModeVerticalRelativePosition(int position)
设置页模式垂直方向相对位置
|
boolean |
addPdf417Content(String content)
设置PDF417内容
|
boolean |
addPdf417ErrorCorrectionLevel(int level)
设置PDF417纠错等级
|
boolean |
addPdf417ModuleWidth(int width)
设置PDF417模块宽度。width取值范围为2~8
|
boolean |
addPdf417Options(int options)
设置PDF417选项
|
boolean |
addPdf417PositionCount(int length)
设置PDF417位置计数(水平长度)
|
boolean |
addPdf417SymbolLevelHeight(int level)
设置PDF417高度等级。
|
boolean |
addPrint()
页模式打印数据。
|
boolean |
addPrintAndFeedLines(byte n)
打印并且走纸多少行
|
boolean |
addPrintAndFeedPaper(byte n)
设置打印后走纸距离
|
boolean |
addPrintAndLineFeed()
进纸一行
|
boolean |
addPrintAndSwitchStandardMode()
页模式打印并切换到标准模式。
|
boolean |
addPrintNvBitmap(byte n,
byte mode) |
boolean |
addPrintPdf417()
打印PDF417
|
boolean |
addPrintQRCode()
打印存储的QRCode
|
boolean |
addQueryPrinterStatus()
打印完成后通知上位机,
read(byte[], int) 方法中接收到打印机的通知。该方法可用于连续打印多份订单 |
boolean |
addRastBitImage(android.graphics.Bitmap bitmap,
int nWidth,
int nMode)
打印光栅位图
|
boolean |
addRastBitImageWithMethod(android.graphics.Bitmap bitmap,
int nWidth,
int nMode,
Command.ImageAlgorithm method)
打印光栅位图 需要选择打印算法,可通过GpUtils.
|
boolean |
addSelectCharacterFont(Command.FONT font)
设置字符类型
|
boolean |
addSelectCodePage(byte page)
设置代码页
|
boolean |
addSelectDefualtLineSpacing()
设置为默认行间距
|
boolean |
addSelectErrorCorrectionLevelForQRCode(byte n)
设置QRCode纠错级别
|
boolean |
addSelectInternationalCharacterSet(Command.CHARACTER_SET set)
设置国际字符集
|
boolean |
addSelectJustification(Command.JUSTIFICATION just)
设置对齐方式
|
boolean |
addSelectKanjiMode()
设置汉字有效
|
boolean |
addSelectOrCancelUserDefineCharacter(Command.ENABLE enable)
设置是否取消自定义字符
|
boolean |
addSelectPageMode()
选择页模式
|
boolean |
addSelectPrintingPositionForHRICharacters(Command.HRI_POSITION position)
设置条码可识别字符
|
boolean |
addSelectPrintModes(Command.FONT font,
Command.ENABLE emphasized,
Command.ENABLE doubleheight,
Command.ENABLE doublewidth,
Command.ENABLE underline)
设置打印模式
|
boolean |
addSelectPrintOrientation(int n)
页模式中设置打印方向。
|
boolean |
addSelectSizeOfModuleForQRCode(byte n)
设置QRCode单元模块大小
|
boolean |
addSelectStandardMode()
选择标准模式。
|
boolean |
addSetAbsolutePrintPosition(short n)
设置绝对打印位置
|
boolean |
addSetAutoSatusBack(Command.ENABLE enable)
设置打印机是否自动返回状态
|
boolean |
addSetBarcodeHeight(byte height)
设置条码高度
|
boolean |
addSetBarcodeWidth(byte width)
设置条码单元宽度
|
boolean |
addSetCharacterSize(Command.WIDTH_ZOOM width,
Command.HEIGHT_ZOOM height)
设置字符放大
|
boolean |
addSetFontForHRICharacter(Command.FONT font)
设置条码字符种类
|
boolean |
addSetHorAndVerMotionUnits(byte x,
byte y)
设置水平和垂直单位距离
|
boolean |
addSetKanjiFontMode(Command.ENABLE DoubleWidth,
Command.ENABLE DoubleHeight,
Command.ENABLE Underline)
设置是否汉字字体
|
boolean |
addSetKanjiLefttandRightSpace(byte left,
byte right)
设置汉字左右间距
|
boolean |
addSetKanjiUnderLine(Command.UNDERLINE_MODE underline)
设置汉字下划线
|
boolean |
addSetLeftMargin(short n)
设置打印左间距
|
boolean |
addSetLineSpacing(byte n)
设置行间距
|
boolean |
addSetPrintArea(int x,
int y,
int width,
int height)
页模式中设置打印区域。
|
boolean |
addSetPrintingAreaWidth(short width)
设置打印宽度
|
boolean |
addSetQuadrupleModeForKanji(Command.ENABLE enable)
设置汉字倍宽倍高
|
boolean |
addSetRelativePrintPosition(short n)
设置相对打印位置
|
boolean |
addSetRightSideCharacterSpacing(byte n)
设置字符右间距
|
boolean |
addSound(byte n,
byte t)
蜂鸣器
|
boolean |
addStoreQRCodeData(String content)
存入QRCode数据在打印机
|
boolean |
addText(int printWidth,
String text,
int fontSize,
boolean bold,
boolean underline)
插入文字
|
boolean |
addText(String text)
插入文字
|
boolean |
addText(String text,
String charsetName)
插入文字
|
boolean |
addTurn90ClockWiseRotatin(Command.ENABLE enable)
设置字符是否旋转90°
|
boolean |
addTurnDoubleStrikeOnOrOff(Command.ENABLE enabel)
设置加重模式
|
boolean |
addTurnEmphasizedModeOnOrOff(Command.ENABLE enabel)
设置加粗模式
|
boolean |
addTurnReverseModeOnOrOff(Command.ENABLE enable)
设置反白模式
|
boolean |
addTurnUnderlineModeOnOrOff(Command.UNDERLINE_MODE underline)
设置下划线
|
boolean |
addTurnUpsideDownModeOnOrOff(Command.ENABLE enable)
设置倒置模式
|
boolean |
addUPCA(String content)
打印UPCA条码
|
boolean |
addUPCE(String content)
方法说明 打印UPCE条码
|
boolean |
addUserCommand(byte[] command)
发送打印机指令。
|
boolean |
addUserCommand(byte[] command,
int offset,
int len,
int time)
发送打印机指令。
|
String |
genCode128(String content) |
String |
genCodeB(String content) |
static EscCommand |
getInstance() |
int |
read(byte[] buffer,
int time)
读取数据。
|
boolean |
RealtimeStatusTransmission(Command.STATUS status)
打印机实时状态请求
|
close, connect, connect, getConnecter, isConnected, setConnecter
public static EscCommand getInstance()
public boolean addHorTab()
public boolean addText(String text)
text
- 文本内容public boolean addText(String text, String charsetName)
text
- 文本内容charsetName
- 字符编码public boolean addText(int printWidth, String text, int fontSize, boolean bold, boolean underline)
printWidth
- 打印机打印宽度text
- 打印内容fontSize
- 字体大小bold
- 设置字体加粗。turn为加粗,否则为正常underline
- 设置下划线。turn为显示下划线,否则显示正常public boolean addArabicText(String text, Command.JUSTIFICATION justification)
text
- 文本内容public boolean addPrintAndLineFeed()
public boolean RealtimeStatusTransmission(Command.STATUS status)
status
- PRINTER_STATUS 打印机状态 PRINTER_OFFLINE 脱机状态 PRINTER_ERROR 错误状态
PRINTER_PAPER 纸张状态public boolean addGeneratePluseAtRealtime(Command.FOOT foot, byte t)
foot
- 钱箱 2脚 F2 钱箱 5脚 F5t
- 脉冲时间 tx100mspublic boolean addSound(byte n, byte t)
n
- n是指蜂鸣器鸣叫次数。t
- t 是指蜂鸣器鸣每次数鸣叫时间为(t × 50)毫秒public boolean addSetRightSideCharacterSpacing(byte n)
n
- 间距长度public boolean addSelectPrintModes(Command.FONT font, Command.ENABLE emphasized, Command.ENABLE doubleheight, Command.ENABLE doublewidth, Command.ENABLE underline)
font
- 选择FONTA or FONTBemphasized
- 是否加粗doubleheight
- 是否倍高doublewidth
- 是否倍宽underline
- 是否下划线public boolean addSetAbsolutePrintPosition(short n)
n
- 与起始打印位置距离public boolean addSelectOrCancelUserDefineCharacter(Command.ENABLE enable)
enable
- 是否取消public boolean addTurnUnderlineModeOnOrOff(Command.UNDERLINE_MODE underline)
underline
- 下划线类型public boolean addSelectDefualtLineSpacing()
public boolean addSetLineSpacing(byte n)
n
- 行间距高度,包含文字public boolean addCancelUserDefinedCharacters(byte n)
n
- 字符编号public boolean addInitializePrinter()
public boolean addTurnEmphasizedModeOnOrOff(Command.ENABLE enabel)
enabel
- 是否加粗public boolean addTurnDoubleStrikeOnOrOff(Command.ENABLE enabel)
enabel
- 是否加重public boolean addPrintAndFeedPaper(byte n)
n
- 走纸长度public boolean addSelectCharacterFont(Command.FONT font)
font
- FONTA or FONTBpublic boolean addSelectInternationalCharacterSet(Command.CHARACTER_SET set)
set
- 字符集编号public boolean addTurn90ClockWiseRotatin(Command.ENABLE enable)
enable
- 是否旋转public boolean addSetRelativePrintPosition(short n)
n
- 与上一字符的相对位置public boolean addSelectJustification(Command.JUSTIFICATION just)
just
- 左 中 右对齐public boolean addPrintAndFeedLines(byte n)
n
- 行数public boolean addGeneratePlus(Command.FOOT foot, byte t1, byte t2)
foot
- 钱箱引脚号t1
- 高电平时间t2
- 低电平时间public boolean addSelectCodePage(byte page)
page
- 代码页编号public boolean addTurnUpsideDownModeOnOrOff(Command.ENABLE enable)
enable
- 是否倒置public boolean addSetCharacterSize(Command.WIDTH_ZOOM width, Command.HEIGHT_ZOOM height)
width
- 宽度放大倍数height
- 高度放大倍数public boolean addTurnReverseModeOnOrOff(Command.ENABLE enable)
enable
- 是否反白public boolean addSelectPrintingPositionForHRICharacters(Command.HRI_POSITION position)
position
- 可识别字符位置public boolean addSetLeftMargin(short n)
n
- 左间距public boolean addSetHorAndVerMotionUnits(byte x, byte y)
x
- 水平单位y
- 垂直单位public boolean addCutAndFeedPaper(byte length)
length
- 走纸距离public boolean addCutPaper()
public boolean addSetPrintingAreaWidth(short width)
width
- 打印宽度public boolean addSetAutoSatusBack(Command.ENABLE enable)
enable
- 是否返回public boolean addSetFontForHRICharacter(Command.FONT font)
font
- FONTA or FONTBpublic boolean addSetBarcodeHeight(byte height)
height
- 高度public boolean addSetBarcodeWidth(byte width)
width
- 条码宽度public boolean addSetKanjiFontMode(Command.ENABLE DoubleWidth, Command.ENABLE DoubleHeight, Command.ENABLE Underline)
DoubleWidth
- 是否倍宽DoubleHeight
- 是否倍高Underline
- 是否下划线public boolean addSelectKanjiMode()
public boolean addSetKanjiUnderLine(Command.UNDERLINE_MODE underline)
underline
- 是否设置汉字下划线public boolean addCancelKanjiMode()
public boolean addSetKanjiLefttandRightSpace(byte left, byte right)
left
- 左间距right
- 右间距public boolean addSetQuadrupleModeForKanji(Command.ENABLE enable)
enable
- 是否开启倍宽倍高public boolean addRastBitImage(android.graphics.Bitmap bitmap, int nWidth, int nMode)
bitmap
- 位图数据nWidth
- 位图宽度nMode
- 光栅位图模式public boolean addOriginRastBitImage(android.graphics.Bitmap bitmap, int nWidth, int nMode)
public boolean addRastBitImageWithMethod(android.graphics.Bitmap bitmap, int nWidth, int nMode, Command.ImageAlgorithm method)
bitmap
- 位图nWidth
- 宽度nMode
- 模式method
- 算法方法 Command.ImageAlgorithm
public boolean addDownloadNvBitImage(android.graphics.Bitmap[] bitmap)
bitmap
- 位图数据public boolean addPrintNvBitmap(byte n, byte mode)
public boolean addUPCA(String content)
content
- 数据范围0-9,长度为11位public boolean addUPCE(String content)
content
- 数据范围0-9,长度为11位,必须以0开头public boolean addEAN13(String content)
content
- 数据范围0-9,长度为12位public boolean addEAN8(String content)
content
- 数据范围0-9,长度为7位public boolean addCODE39(String content)
content
- 数据范围0-9 A-Z SP $ % + - . /public boolean addITF(String content)
content
- 数据范围 0-9 数据长度 偶数个public boolean addBarcode(String content)
content
- 数据范围 0-9 $ + - . / : 数据前后需插入A-Dpublic boolean addCODE93(String content)
content
- 数据范围0x00-0x7fpublic boolean addCODE128(String content)
content
- 数据范围0x00-0x7fpublic boolean addSelectSizeOfModuleForQRCode(byte n)
n
- QRCode单元模块大小public boolean addSelectErrorCorrectionLevelForQRCode(byte n)
n
- 纠错级别public boolean addStoreQRCodeData(String content)
content
- RCode数据public boolean addPrintQRCode()
public boolean addQueryPrinterStatus()
read(byte[], int)
方法中接收到打印机的通知。该方法可用于连续打印多份订单public boolean addBlackMark(boolean isOpenBlackMark)
isOpenBlackMark
- true 打开黑标模式,false 关闭黑标模式public boolean addBlackMarkPagerLength(int length)
length
- 黑标纸长度public boolean addBlackMarkWidth(int width)
width
- 黑标宽度public boolean addBlackMarkStartPrintPosition(int vertical)
vertical
- 与黑标的垂直距离。单位:mm。public boolean addBlackMarkCutterPosition(int vertical)
vertical
- 切纸位置与黑标之间的垂直距离。 单位:mm.public boolean addPageModeVerticalAbsolutePosition(int position)
position
- 垂直方向绝对位置public boolean addPageModeVerticalRelativePosition(int position)
position
- 垂直方向相对位置public boolean addSelectPageMode()
public boolean addSelectStandardMode()
public boolean addSelectPrintOrientation(int n)
n
- 指定打印区域的方向打印起始位置。
0 ≤ n ≤ 3 或 48 ≤ n ≤ 51
n=0(或n=48) 打印方向由左到右;
n=1(或n=49)打印方向由下到上;
n=2(或n=50) 打印方向由右到左;
n=3(或n=51) 打印方向由上到下。public boolean addSetPrintArea(int x, int y, int width, int height)
x
- 横向起始位置。y
- 纵向起始位置。width
- 打印区域宽度。height
- 打印区域高度。public boolean addPrintAndSwitchStandardMode()
public boolean addCancelPrintData()
public boolean addPrint()
public boolean addPdf417PositionCount(int length)
length
- 长度。length范围为0~30public boolean addPdf417ModuleWidth(int width)
public boolean addPdf417SymbolLevelHeight(int level)
level
- 高度等级。范围为2~8public boolean addPdf417ErrorCorrectionLevel(int level)
level
- 纠错等级。纠错等级范围为 48~56。
level=48纠错等级0;level=49纠错等级1;level=50纠错等级2;level=51纠错等级3;level=52纠错等级4;level=53纠错等级5;level=54纠错等级6;level=55纠错等级7;level=56纠错等级8。public boolean addPdf417Options(int options)
options
- PDF417选项。options=0标准PDF417,options=1简单PDF417。public boolean addPdf417Content(String content)
content
- PDF417 contentpublic boolean addPrintPdf417()
public boolean addUserCommand(byte[] command)
command
- 打印机指令public boolean addUserCommand(byte[] command, int offset, int len, int time)
command
- 打印机指令。offset
- 偏移量。len
- 长度。time
- 超时时间,单位:毫秒(ms)。public int read(byte[] buffer, int time) throws IOException
buffer
- 存放从打印机中读取数据的缓存区域。time
- 等待时间,单位:毫秒(ms)。IOException
- 读取数据异常。