001 /* 002 * =========================================================================================== 003 * = COPYRIGHT 004 * PAX Computer Technology (Shenzhen) Co., Ltd. PROPRIETARY INFORMATION 005 * This software is supplied under the terms of a license agreement or nondisclosure 006 * agreement with PAX Computer Technology (Shenzhen) Co., Ltd. and may not be copied or 007 * disclosed except in accordance with the terms in that agreement. 008 * Copyright (C) 2017-2023 PAX Computer Technology (Shenzhen) Co., Ltd. All rights reserved. 009 * Description: // Detail description about the function of this module, 010 * // interfaces with the other modules, and dependencies. 011 * Revision History: 012 * Date Author Action 013 * 2017/04/01 PAX Create/Add/Modify/Delete 014 * =========================================================================================== 015 */ 016 017package com.pax.dal; 018 019import android.graphics.Bitmap; 020 021import com.pax.dal.entity.EFontTypeAscii; 022import com.pax.dal.entity.EFontTypeExtCode; 023import com.pax.dal.exceptions.PrinterDevException; 024import com.pax.dal.IPrinListener; 025 026 /** 027 * <div class="zh">关于Monitor Printer的API。 如果开启权限检查,需在AndroidManifest下添加权限:"com.pax.permission.PRINTER"</div> 028 * <div class="en">API for Monitor Printer. If permission check is enabled, you need to add permission under AndroidManifest: "com.pax.permission.PRINTER".</div> 029 */ 030public interface IPrinter { 031 /** 032 * <div class="zh"> 打印初始化 </div> <div class="en"> Printer Initialization </div> 033 * 034 * @throws PrinterDevException 035 */ 036 public void init() throws PrinterDevException; 037 038 /** 039 * <div class="zh"> 设置打印的字体 </div> <div class="en"> set print font </div> 040 * 041 * 042 * @param asciiFontType 043 * {@link EFontTypeAscii} <div class="zh"> Ascii码的字体设置<br/> 044 * <ul> 045 * <li>{@link EFontTypeAscii#FONT_8_16}:8x16字体[基本]</li> 046 * <li>{@link EFontTypeAscii#FONT_12_24}:12x24字体[基本]</li> 047 * <li>{@link EFontTypeAscii#FONT_8_32}:8x16字体纵向放大</li> 048 * <li>{@link EFontTypeAscii#FONT_12_48}:12x24字体纵向放大</li> 049 * <li>{@link EFontTypeAscii#FONT_16_16}:8x16字体横向放大</li> 050 * <li>{@link EFontTypeAscii#FONT_24_24}:12x24字体横向放大</li> 051 * <li>{@link EFontTypeAscii#FONT_16_32}:8x16字体整体放大</li> 052 * <li>{@link EFontTypeAscii#FONT_24_48}:12x24字体整体放大</li> 053 * </ul> 054 * </div> <div class="en"> 055 * <ul> 056 * <li>{@link EFontTypeAscii#FONT_8_16}:8x16 font (Basic)</li> 057 * <li>{@link EFontTypeAscii#FONT_12_24}:12x24 font (Basic)</li> 058 * <li>{@link EFontTypeAscii#FONT_8_32}:8x16 font (enlarge vertically)</li> 059 * <li>{@link EFontTypeAscii#FONT_12_48}:12x24 font (enlarge vertically)</li> 060 * <li>{@link EFontTypeAscii#FONT_16_16}:8x16 font (enlarge horizontally)</li> 061 * <li>{@link EFontTypeAscii#FONT_24_24}:12x24 font (enlarge horizontally)</li> 062 * <li>{@link EFontTypeAscii#FONT_16_32}:8x16 font (enlarge on both levels)</li> 063 * <li>{@link EFontTypeAscii#FONT_24_48}:12x24 font (enlarge on both levels)</li> 064 * </ul> 065 * </div> 066 * 067 * @param fontTypeExtCode 068 * {@link EFontTypeExtCode} <div class="zh"> 扩展码的字体设置<br/> 069 * <ul> 070 * <li>{@link EFontTypeExtCode#FONT_16_16}:16x16字体[基本]</li> 071 * <li>{@link EFontTypeExtCode#FONT_24_24}:24x24字体[基本]</li> 072 * <li>{@link EFontTypeExtCode#FONT_16_32}:16x16字体纵向放大</li> 073 * <li>{@link EFontTypeExtCode#FONT_24_48}:24x24字体纵向放大</li> 074 * <li>{@link EFontTypeExtCode#FONT_32_16}:16x16字体横向放大</li> 075 * <li>{@link EFontTypeExtCode#FONT_48_24}:24x24字体横向放大</li> 076 * <li>{@link EFontTypeExtCode#FONT_32_32}:16x16字体整体放大</li> 077 * <li>{@link EFontTypeExtCode#FONT_48_48}:24x24字体整体放大</li> 078 * </ul> 079 * </div> <div class="en"> font set for extended code characters 080 * <ul> 081 * <li>FONT_16_16 -16x16 font (Basic)</li> 082 * <li>FONT_24_24 -24x24 font (Basic)</li> 083 * <li>FONT_16_32 -16x16 font (enlarge vertically)</li> 084 * <li>FONT_24_48 -24x24 font (enlarge vertically)</li> 085 * <li>FONT_48_24 -16x16 font (enlarge horizontally)</li> 086 * <li>FONT_32_32 -24x24 font (enlarge horizontally)</li> 087 * <li>FONT_48_24 -16x16 font (enlarge on both levels)</li> 088 * <li>FONT_48_48 -24x24 font (enlarge on both levels)</li> 089 * </ul> 090 * </div> 091 * 092 * @throws PrinterDevException 093 */ 094 public void fontSet(EFontTypeAscii asciiFontType, EFontTypeExtCode fontTypeExtCode) throws PrinterDevException; 095 096 /** 097 * <div class="zh"> 设置打印字间距、行间距。<br/> 098 * <ul> 099 * <li>在对打印机有效设置后将一直有效,直至下次设置或调用{@link IPrinter#init()}</li> 100 * <li>打印机的默认字间距为0</li> 101 * <li>打印机的默认行间距热敏为0,针打为2</li> 102 * <li>打印机的行间距极大值为255<br/> 103 * <li>打印机的字间距极大值为255,针式打印机最大间距为60</li> 104 * </ul> 105 * </div> <div class="en"> 106 * <ul> 107 * <li>Settings will be valid until they are set again or {@link IPrinter#init()} is called;</li> 108 * <li>Printing character space is 0 by default;</li> 109 * <li>Printing line space is 0 for thermal and 2 for stylus printer;</li> 110 * <li>The maximum line space can be 255;</li> 111 * <li>The maximum character space can be 255. (stylus printer is 60);</li> 112 * </ul> 113 * </div> 114 * 115 * @param wordSpace 116 * <div class="zh"> 字间距[像素点] </div> <div class="en"> Character space [pixels] </div> 117 * 118 * @param lineSpace 119 * <div class="zh"> 行间距[像素点] </div> <div class="en"> Line space [pixels] </div> 120 * 121 * @throws PrinterDevException 122 */ 123 public void spaceSet(byte wordSpace, byte lineSpace) throws PrinterDevException; 124 125 /** 126 * <div class="zh"> 让打印机走纸pixel个像素点<br/> 127 * <ul> 128 * <li>如果pixel为正数则进纸,pixel为负数则退纸,pixel为0时无动作。</li> 129 * <li>该指令为一次打印动作,即在执行后即刻失效。</li> 130 * <li>对于针式打印机,pixel小于-255或者大于255,该函数不做任何动作</li> 131 * </ul> 132 * </div> <div class="en"> 133 * <ul> 134 * <li>If the pixel value is positive, then the paper will feed forward. If it is negative, then feed backward. If 135 * it is 0,then no action.</li> 136 * <li>This is a one time action.</li> 137 * <li>For the stylus printer, there is no action when pixel less than -255 or pixel greater than 255.</li> 138 * </ul> 139 * </div> 140 * 141 * @param pixel 142 * <div class="zh"> 像素点个数 </div> <div class="en"> number of pixels </div> 143 * 144 * @throws PrinterDevException 145 */ 146 public void step(int pixel) throws PrinterDevException; 147 148 /** 149 * <div class="zh"> 打印字符串<br/> 150 * <ul> 151 * <li>支持打印串中出现‘\n‘[换行]、‘\f‘[换页]控制字符;</li> 152 * <li>如果打印数据包过长,则程序将溢出;</li> 153 * <li>如果打印字符串超出打印范围,将自动换行后继续打印;</li> 154 * <li>缓冲区最大为2048字节。</li> 155 * <li>将str存入打印缓冲区,在调用{@link IPrinter#start()}后,按照写入缓冲区的顺序,开始打印缓冲区里的数据。</li> 156 * </ul> 157 * </div> <div class="en"> 158 * <ul> 159 * <li>Support '\n' (new line) and '\f' (new page) control characters;</li> 160 * <li>If the printing data package is too long, then the printing program will overflow;</li> 161 * <li>If the string is longer than the current printing line, change line automatically and continue printing.</li> 162 * <li>The maximum buffer size is 2048 bytes.</li> 163 * <li> 164 * Store str in printing buffer, and print data in printing buffer in sequence after calling 165 * {@link IPrinter#start()}.</li> 166 * </ul> 167 * </div> 168 * 169 * @param str 170 * <div class="zh"> 打印字符串 </div> <div class="en"> print string </div> 171 * 172 * @param charset 173 * <div class="zh"> Str字符集,为null时,默认为UTF-8字符集 </div> <div class="en"> When character set is NULL,default 174 * to UTF-8. </div> 175 * 176 * @throws PrinterDevException 177 */ 178 public void printStr(String str, String charset) throws PrinterDevException; 179 180 /** 181 * <div class="zh"> 打印图片 </div> <div class="en"> Print bitmap </div> 182 * 183 * @param bitmap 184 * <div class="zh"> 需打印的图片信息 </div> <div class="en"> Picture information. </div> 185 * 186 * @throws PrinterDevException 187 */ 188 public void printBitmap(Bitmap bitmap) throws PrinterDevException; 189 190 /** 191 * <div class="zh"> 打印图片 </div> <div class="en"> Print bitmap </div> 192 * 193 * @param bitmap 194 * <div class="zh"> 需打印的图片</div> <div class="en"> bitmap. </div> 195 * @param grayThreshold 196 * <div class="zh"> 图像灰度阀值 0-255 </div> <div class="en"> gray threshold . between 0 and 255 </div> 197 * 198 * @throws PrinterDevException 199 */ 200 public void printBitmapWithMonoThreshold(Bitmap bitmap, int grayThreshold) throws PrinterDevException; 201 202 /** 203 * <div class="zh"> 启动打印机,将缓冲区里的数据打印出来, 此接口为同步接口<br/> 204 * <ul> 205 * <li>在调用该函数后,打印机将进行打印,直到打印结束后才返回;</li> 206 * <li>在打印结束后,该函数会返回打印状态,因此可不必再查询打印状态;</li> 207 * <li>如果打印机在成功完成打印任务后,再次调用该函数,则会将单据重打一遍。</li> 208 * <li>使用上应遵循公式:每行的点数 = 字符的高度 + 行距。总的点数 =每行的点数 * 行数 。总的点数要小于30000,默认字符高度是24。</li> 209 * </ul> 210 * 211 * </div> <div class="en"> Start printer and prints data in buffer.This is synchronous interface. 212 * <ul> 213 * <li>After calling this function, the printer will perform the printing task and return after completed the whole 214 * printing task.</li> 215 * <li> 216 * After completed the whole printing task, this function will return the printer status in return value. Therefore 217 * the check printer status is not required.</li> 218 * <li>If the printing process is completed, recalling this function will reprint the slip.</li> 219 * <li>Use should follow the formula: the number of points per line = the height of the character + the line space. 220 * Total number of points = number of points per row * number of rows.The total number of points should be less than 30,000, 221 * and the default character height is 24.</li> 222 * </ul> 223 * 224 * </div> 225 * 226 * @return <div class="zh"> 227 * <ul> 228 * <li>0: 正常</li> 229 * <li>1: 打印机忙</li> 230 * <li>2: 打印机缺纸</li> 231 * <li>3: 打印数据包格式错</li> 232 * <li>4: 打印机故障</li> 233 * <li>8: 打印机过热</li> 234 * <li>9: 打印机电压过低</li> 235 * <li>-16:打印未完成</li> 236 * <li>-6:切刀异常(支持E500,E800)</li> 237 * <li>-5:开盖错误(支持E500,E800)</li> 238 * <li>-4:打印机未安装字库</li> 239 * <li>-2:数据包过长</li> 240 * </ul> 241 * </div> <div class="en"> 242 * <ul> 243 * <li>0- Success</li> 244 * <li>1- Printer is busy</li> 245 * <li>2- Out of paper</li> 246 * <li>3- The format of print data packet error</li> 247 * <li>4- Printer malfunctions</li> 248 * <li>8- Printer over heats</li> 249 * <li>9- Printer voltage is too low</li> 250 * <li>-16- Printing is unfinished</li> 251 * <li>-6: cut jam error(only support:E500,E800)</li> 252 * <li>-5: cover open error(only support:E500,E800)</li> 253 * <li>-4- The printer has not installed font library</li> 254 * <li>-2- Data package is too long</li> 255 * </ul> 256 * </div> 257 * 258 * @throws PrinterDevException 259 */ 260 public int start() throws PrinterDevException; 261 262 /** 263 * <div class="zh"> 查询当前打印状态 </div> <div class="en"> Check current printer status. </div> 264 * 265 * @return <div class="zh"> 266 * <ul> 267 * <li>0: 正常</li> 268 * <li>1: 打印机忙</li> 269 * <li>2: 打印机缺纸</li> 270 * <li>3: 打印数据包格式错</li> 271 * <li>4: 打印机故障</li> 272 * <li>8: 打印机过热</li> 273 * <li>9: 打印机电压过低</li> 274 * <li>-16:打印未完成</li> 275 * <li>-6:切刀异常(支持E500,E800)</li> 276 * <li>-5:开盖错误(支持E500,E800,SK600,SK800)</li> 277 * <li>-4:打印机未安装字库</li> 278 * <li>-2:数据包过长</li> 279 * </ul> 280 * </div> <div class="en"> 281 * <ul> 282 * <li>0- Success</li> 283 * <li>1- Printer is busy</li> 284 * <li>2- Out of paper</li> 285 * <li>3- The format of print data packet error</li> 286 * <li>4- Printer malfunctions</li> 287 * <li>8- Printer over heats</li> 288 * <li>9- Printer voltage is too low</li> 289 * <li>-16- Printing is unfinished</li> 290 * <li>-6: cut jam error(only support:E500,E800)</li> 291 * <li>-5: cover open error(only support:E500,E800,SK600,SK800)</li> 292 * <li>-4- The printer has not installed font library</li> 293 * <li>-2- Data package is too long</li> 294 * </ul> 295 * </div> 296 * 297 * @throws PrinterDevException 298 */ 299 public int getStatus() throws PrinterDevException; 300 301 /** 302 * <div class="zh"> 设置字符打印左边界<br/> 303 * 默认边界为0<br/> 304 * 当输入的参数超过最大值时,按照最大值设置<br/> 305 * </div> <div class="en"> Set character printing left boundary. Default value is 0. If the input value exceed the 306 * maximum, the maximum one will be used. </div> 307 * 308 * @param indent 309 * <div class="zh"> 左边界空白像素点,范围:0~300 </div> <div class="en"> 0~300 Vacant dots in left boundary, range: 310 * 0~300 </div> 311 * 312 * @throws PrinterDevException 313 */ 314 public void leftIndent(int indent) throws PrinterDevException; 315 316 /** 317 * <div class="zh"> 取得当前已打印的点阵行 </div> <div class="en"> Get current printed dot line for slip alignment. </div> 318 * 319 * @return <div class="zh"> 当前已打印的点阵行 </div> <div class="en"> Current dot line. </div> 320 * 321 * @throws PrinterDevException 322 */ 323 public int getDotLine() throws PrinterDevException; 324 325 /** 326 * <div class="zh"> 设置打印黑度等级 </div> <div class="en"> Set printing gray level. </div> 327 * 328 * @param level 329 * <div class="zh"> 330 * <ul> 331 * <li>Level=0 保留</li> 332 * <li>Level=1 缺省黑度,即普通打印单</li> 333 * <li>Level=2 保留</li> 334 * <li>Level=3 双层热敏打印</li> 335 * <li>Level=4 双层热敏打印,比3的黑度更高</li> 336 * <li>Level=[50~500] 黑度按照缺省黑度百分比进行设置,如50是把黑度设置为默认值的50%,500则把黑度设置为500%</li> 337 * </ul> 338 * </div> <div class="en"> 339 * <ul> 340 * <li>Level=0 -Reserved</li> 341 * <li>Level=1 -Default level, normal print slip</li> 342 * <li>Level=2 -Reserved</li> 343 * <li>Level=3 -Two-layer thermal printing</li> 344 * <li>Level=4 -Two-layer thermal printing, higher gray level than 3</li> 345 * <li>Level=[50~500] -Gray level is set according to percentage of default value. If it is 50, then set 346 * gray level to be 50% of default value; If it is 500, then set grey level to be 500% of default value.</li> 347 * </ul> 348 * </div> 349 * 350 * @throws PrinterDevException 351 */ 352 public void setGray(int level) throws PrinterDevException; 353 354 /** 355 * <div class="zh"> 设置打印字体宽度,可在基本字体上实现双倍宽度的打印 </div> <div class="en"> Set printing font which is based on base font 356 * to double width. </div> 357 * 358 * @param isAscDouble 359 * <div class="zh"> 单内码字体是否倍宽 </div> <div class="en"> If the single coding font is double width or not. 360 * </div> 361 * 362 * @param isLocalDouble 363 * <div class="zh"> 多内码字体是否倍宽 </div> <div class="en"> If the multi coding font is double width or not. 364 * </div> 365 * 366 * @throws PrinterDevException 367 */ 368 public void doubleWidth(boolean isAscDouble, boolean isLocalDouble) throws PrinterDevException; 369 370 /** 371 * <div class="zh"> 设置打印字体高度,可在基本字体上实现双倍高度的打印。 </div> <div class="en"> Set printing font which is based on base font 372 * to double height. </div> 373 * 374 * @param isAscDouble 375 * <div class="zh"> 单内码字体是否倍高 </div> <div class="en"> If the single coding font is double height or not. 376 * </div> 377 * @param isLocalDouble 378 * <div class="zh"> 多内码字体是否倍高</div> <div class="en"> If the multi coding font is double height or not. 379 * </div> 380 * @throws PrinterDevException 381 */ 382 public void doubleHeight(boolean isAscDouble, boolean isLocalDouble) throws PrinterDevException; 383 384 /** 385 * <div class="zh"> 设置反显打印,缺省为正常打印。 </div> <div class="en"> Invert Pinter Setting,default to normal printing. </div> 386 * 387 * @param isInvert 388 * <div class="zh"> 389 * <ul> 390 * <li>true-反显</li> 391 * <li>false-正常</li> 392 * </ul> 393 * </div> <div class="en"> 394 * <ul> 395 * <li>true -Invert</li> 396 * <li>false -Normal</li> 397 * </ul> 398 * </div> 399 * 400 * @throws PrinterDevException 401 */ 402 public void invert(boolean isInvert) throws PrinterDevException; 403 404 /** 405 * <div class="zh"> 切纸 </div> <div class="en"> cut paper </div> 406 * 407 * @param mode 408 * <div class="zh"> mode =0时, 表示全部切纸 ;mode =1时, 表示部分切纸</div> <div class="en"> mode =0: full paper 409 * cut;mode =1:Partial paper cutting</div> 410 * @throws PrinterDevException 411 */ 412 public void cutPaper(int mode) throws PrinterDevException; 413 414 /** 415 * <div class="zh"> 获取当前切纸模式 </div> <div class="en"> get cut mode </div> 416 * 417 * @return <div class="zh"> 418 * <ul> 419 * <li>0:仅支持全切</li> 420 * <li>1:仅支持半切</li> 421 * <li>2:支持全切 和 半切</li> 422 * <li>-1:无切刀,不支持切纸</li> 423 * </ul> 424 * </div> <div class="en"> 425 * <ul> 426 * <li>0:Only support full paper cut</li> 427 * <li>1:Only support partial paper cutting</li> 428 * <li>2:support partial paper and full paper cutting</li> 429 * <li>-1:No cutting knife,not support</li> 430 * </ul> 431 * </div> 432 * @throws PrinterDevException 433 */ 434 public int getCutMode() throws PrinterDevException; 435 436 /** 437 * <div class="zh"> 直接打印Bitmap,异步封装接口 (不能与除了{@link #setGray(int)}之外的Printer接口直接混用)。print前后会自动init,但灰度值会保留</div> <div 438 * class="en"> Print bitmap directly,asynchronous encapsulation interface(Cannot mix with the Printer interface 439 * except {@link #setGray (int)}).Init automatically print before and after,but the grey value will be saved.</div> 440 * 441 * @param bitmap 442 * <div class="zh">位图,不能为null</div> <div class="en">bitmap,can't be null</div> 443 * @param listener 444 * <div class="zh">监听器({@link IPinterListener}),为null时直接打印无结果回调</div> <div class="en">listener( 445 * {@link IPinterListener} ),direct print without result callback for null</div> 446 */ 447 public void print(Bitmap bitmap, IPinterListener listener); 448 449 /** 450 * <div class="zh"> 直接打印Bitmap,异步封装接口 (不能与除了{@link #setGray(int)}之外的Printer接口直接混用)。print前后会自动init,但灰度值会保留</div> <div 451 * class="en"> Print bitmap directly,asynchronous encapsulation interface(Cannot mix with the Printer interface 452 * except {@link #setGray (int)}).Init automatically print before and after,but the grey value will be saved.</div> 453 * 454 * @param bitmap 455 * <div class="zh">位图,不能为null</div> <div class="en">bitmap,can't be null</div> 456 * @param cutMode 457 * <div class="zh">切纸模式, mode =0时, 表示全部切纸 ;mode =1时, 表示部分切纸</div> <div class="en">cut mode,mode =0: full 458 * paper cut;mode =1:Partial paper cutting</div> 459 * @param listener 460 * <div class="zh">监听器({@link IPinterListener}),为null时直接打印无结果回调</div> <div class="en">listener( 461 * {@link IPinterListener} ),direct print without result callback for null</div> 462 * @since V2.03.00 463 */ 464 public void print(Bitmap bitmap, int cutMode, IPinterListener listener); 465 466 /** 467 * <div class="zh"> 打印Bitmap时的监听器 </div> <div class="en">The listener to print Bitmap </div> 468 * 469 */ 470 public interface IPinterListener { 471 472 /** 473 * <div class="zh"> 打印成功回调 </div> <div class="en"> Print the success callback </div> 474 */ 475 public void onSucc(); 476 477 /** 478 * <div class="zh"> 打印失败回调 </div> <div class="en"> Print the error callback </div> 479 * 480 * @param errCode 481 * <div class="zh"> 482 * <ul> 483 * <li>0: 正常</li> 484 * <li>1: 打印机忙</li> 485 * <li>2: 打印机缺纸</li> 486 * <li>3: 打印数据包格式错</li> 487 * <li>4: 打印机故障</li> 488 * <li>8: 打印机过热</li> 489 * <li>9: 打印机电压过低</li> 490 * <li>-16:打印未完成</li> 491 * <li>-6:切刀异常(支持E500,E800)</li> 492 * <li>-5:开盖错误(支持E500,E800)</li> 493 * <li>-4:打印机未安装字库</li> 494 * <li>-2:数据包过长</li> 495 * </ul> 496 * </div> <div class="en"> 497 * <ul> 498 * <li>0- Success</li> 499 * <li>1- Printer is busy</li> 500 * <li>2- Out of paper</li> 501 * <li>3- The format of print data packet error</li> 502 * <li>4- Printer malfunctions</li> 503 * <li>8- Printer over heats</li> 504 * <li>9- Printer voltage is too low</li> 505 * <li>-16- Printing is unfinished</li> 506 * <li>-6: cut jam error(only support:E500,E800)</li> 507 * <li>-5: cover open error(only support:E500,E800)</li> 508 * <li>-4- The printer has not installed font library</li> 509 * <li>-2- Data package is too long</li> 510 * </ul> 511 * </div> 512 * 513 */ 514 public void onError(int errCode); 515 516 } 517 518 /** 519 * <div class="zh">设置打印机字体</div> <div class="en">set ptinter font path.</div> 520 * 521 * @param fontPath 522 * <div class="zh">字库路径</div> <div class="en">font path</div> 523 * @throws PrinterDevException 524 */ 525 void setFontPath(String fontPath) throws PrinterDevException; 526 527 /** 528 * <div class="zh">设置切纸模式。打印完成后立刻切纸。提示: 请在{@link #start()}前调用该方法。</div> 529 * <div class="en">Set the cutting mode. Cut the paper immediately after printing. Tip: Please call this method before {@link #start()}.</div> 530 * 531 * @param mode <div class="zh">切纸模式。 532 * <ul> 533 * <li>-1: 不切纸。</li> 534 * <li>0: 全部切纸。</li> 535 * <li>1: 部分切纸。</li> 536 * </ul> 537 * </div> <div class="en"> 538 * <ul> 539 * <li>-1: Do not cut paper.</li> 540 * <li>0: Full paper cut.</li> 541 * <li>1: Partial paper cut.</li> 542 * </ul> 543 * </div> 544 * @throws PrinterDevException PrinterDevException 545 * @since V3.22.00 546 */ 547 void presetCutPaper(int mode) throws PrinterDevException; 548 549 /** 550 * <div class="zh">设置打印纸尺寸(目前SK700支持)注意:设置后需重启设备才能生效 551 * </div> <div class="en">Set the paper size (currently supported by SK700) Note: After setting, you need to restart the device to take effect.</div> 552 * 553 * @param size <div class="zh">打印纸尺寸(支持2寸或3寸)</div> <div class="en">Printing paper size (support 2 inches or 3 inches)</div> 554 * @return <div class="zh">true: 设置成功, false: 设置失败 </div> <div class="en">true: set successfully, false: set failed</div> 555 * @throws PrinterDevException 556 */ 557 boolean setPrinterSize(int size) throws PrinterDevException; 558 559 /** 560 * <div class="zh">获取打印纸尺寸(目前SK700支持) 561 * </div> <div class="en">Get the paper size (currently supported by SK700)</div> 562 * 563 * @return <div class="zh">打印纸尺寸</div> <div class="en">paper size</div> 564 * @throws PrinterDevException 565 */ 566 int getPrinterSize () throws PrinterDevException; 567 568 /** 569 * <div class="zh">检查低功率打印是否开启 570 * </div> <div class="en">Check whether low-power printing is enabled</div> 571 * 572 * @return <div class="zh">true:低功率打印已开启 false:低功率打印已关闭</div> <div class="en">true: Low-power printing is enabled. false: low-power printing is disabled</div> 573 * @throws PrinterDevException 574 */ 575 boolean isLowPowerPrintEnabled () throws PrinterDevException; 576 577 /** 578 * <div class="zh">开启或关闭低功率打印 579 * </div> <div class="en">Enable or disable low-power printing</div> 580 * 581 * @param enable <div class="zh">true:开启低功率打印功能 false:关闭低功率打印功能 </div> <div class="en">true: enables low-power printing. false: Disables low-power printing</div> 582 * @throws PrinterDevException 583 */ 584 void enableLowPowerPrint (boolean enable) throws PrinterDevException; 585 586 /** 587 * <div class="zh">设置打印对齐模式 588 * </div> <div class="en">Set print alignment mode</div> 589 * 590 * @param alignMode <div class="zh">打印对齐模式,0为左对齐,1为居中对齐,2为右对齐 </div> 591 * <div class="en">Print alignment mode, 0 is left alignment, 1 is center alignment, 2 is right alignment</div> 592 * @throws PrinterDevException 593 */ 594 void setAlignMode(short alignMode) throws PrinterDevException; 595 596 /** 597 * <div class="zh">打印双色位图 598 * </div> <div class="en">Print a two-color bitmap</div> 599 * 600 * @param bitmap <div class="zh">打印双色位图的大小限制:如果位图的宽度超过打印机的限制,将会裁剪图片的右边 </div> 601 * <div class="en">Size limit for printing a two-color bitmap: If the width of the bitmap exceeds the printer's limit, the right side of the picture will be cropped</div> 602 * 603 * @param grayThreshold <div class="zh">图像灰度阀值 0-255</div> 604 * <div class="en">Gray threshold . between 0 and 255</div> 605 * @throws PrinterDevException 606 * 607 * @since V4.09.00 608 */ 609 void printColorBitmapWithMonoThreshold(Bitmap bitmap, int grayThreshold) throws PrinterDevException; 610 611 /** 612 * <div class="zh">打印双色位图 613 * </div> <div class="en">Print a two-color bitmap</div> 614 * 615 * @param bitmap <div class="zh">打印双色位图的大小限制:如果位图的宽度超过打印机的限制,将会裁剪图片的右边 </div> 616 * <div class="en">Size limit for printing a two-color bitmap: If the width of the bitmap exceeds the printer's limit, the right side of the picture will be cropped</div> 617 * 618 * @throws PrinterDevException 619 * 620 * @since V4.09.00 621 */ 622 void printColorBitmap(Bitmap bitmap) throws PrinterDevException; 623 624 /** 625 * <div class="zh">设置彩色打印的黑值跟彩色值 626 * </div> <div class="en">Set the black value and color value for color printing</div> 627 * 628 * @param blackLevel <div class="zh">黑值</div> 629 * <div class="en">Black number</div> 630 * 631 * @param colorLevel <div class="zh">彩色值</div> 632 * <div class="en">Chroma value</div> 633 * @throws PrinterDevException 634 * 635 * @since V4.09.00 636 */ 637 void setColorGray(int blackLevel,int colorLevel) throws PrinterDevException; 638 639 /** 640 * <div class="zh"> 启动打印机,将缓冲区里的数据打印出来, 同时监听当前打印的行数,此接口为同步接口<br/> 641 * <ul> 642 * <li>在调用该函数后,打印机将进行打印,直到打印结束后才返回;</li> 643 * <li>在打印结束后,该函数会返回打印状态,因此可不必再查询打印状态;</li> 644 * <li>如果打印机在成功完成打印任务后,再次调用该函数,则会将单据重打一遍。</li> 645 * <li>使用上应遵循公式:每行的点数 = 字符的高度 + 行距。总的点数 =每行的点数 * 行数 。总的点数要小于30000,默认字符高度是24。</li> 646 * </ul> 647 * 648 * </div> <div class="en"> Start printer and prints data in buffer,while monitoring the number of lines currently printed,This is synchronous interface. 649 * <ul> 650 * <li>After calling this function, the printer will perform the printing task and return after completed the whole 651 * printing task.</li> 652 * <li> 653 * After completed the whole printing task, this function will return the printer status in return value. Therefore 654 * the check printer status is not required.</li> 655 * <li>If the printing process is completed, recalling this function will reprint the slip.</li> 656 * <li>Use should follow the formula: the number of points per line = the height of the character + the line space. 657 * Total number of points = number of points per row * number of rows.The total number of points should be less than 30,000, 658 * and the default character height is 24.</li> 659 * </ul> 660 * 661 * </div> 662 * 663 * @return <div class="zh"> 664 * <ul> 665 * <li>0: 正常</li> 666 * <li>1: 打印机忙</li> 667 * <li>2: 打印机缺纸</li> 668 * <li>3: 打印数据包格式错</li> 669 * <li>4: 打印机故障</li> 670 * <li>8: 打印机过热</li> 671 * <li>9: 打印机电压过低</li> 672 * <li>-16:打印未完成</li> 673 * <li>-6:切刀异常(支持E500,E800)</li> 674 * <li>-5:开盖错误(支持E500,E800)</li> 675 * <li>-4:打印机未安装字库</li> 676 * <li>-2:数据包过长</li> 677 * </ul> 678 * </div> <div class="en"> 679 * <ul> 680 * <li>0- Success</li> 681 * <li>1- Printer is busy</li> 682 * <li>2- Out of paper</li> 683 * <li>3- The format of print data packet error</li> 684 * <li>4- Printer malfunctions</li> 685 * <li>8- Printer over heats</li> 686 * <li>9- Printer voltage is too low</li> 687 * <li>-16- Printing is unfinished</li> 688 * <li>-6: cut jam error(only support:E500,E800)</li> 689 * <li>-5: cover open error(only support:E500,E800)</li> 690 * <li>-4- The printer has not installed font library</li> 691 * <li>-2- Data package is too long</li> 692 * </ul> 693 * </div> 694 * 695 * @throws PrinterDevException 696 * @since V4.18.00 697 */ 698 public int start(IPrinListener listener) throws PrinterDevException; 699}