com.pax.dal

Interface IPrinter



  • public interface IPrinter
    关于Monitor Printer的API。 如果开启权限检查,需在AndroidManifest下添加权限:"com.pax.permission.PRINTER"
    API for Monitor Printer. If permission check is enabled, you need to add permission under AndroidManifest: "com.pax.permission.PRINTER".
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface and Description
      static interface  IPrinter.IPinterListener
      打印Bitmap时的监听器
      The listener to print Bitmap
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      void cutPaper(int mode)
      切纸
      cut paper
      void doubleHeight(boolean isAscDouble, boolean isLocalDouble)
      设置打印字体高度,可在基本字体上实现双倍高度的打印。
      Set printing font which is based on base font to double height.
      void doubleWidth(boolean isAscDouble, boolean isLocalDouble)
      设置打印字体宽度,可在基本字体上实现双倍宽度的打印
      Set printing font which is based on base font to double width.
      void enableLowPowerPrint(boolean enable)
      开启或关闭低功率打印
      Enable or disable low-power printing
      void fontSet(EFontTypeAscii asciiFontType, EFontTypeExtCode fontTypeExtCode)
      设置打印的字体
      set print font
      int getCutMode()
      获取当前切纸模式
      get cut mode
      int getDotLine()
      取得当前已打印的点阵行
      Get current printed dot line for slip alignment.
      int getPrinterSize()
      获取打印纸尺寸(目前SK700支持)
      Get the paper size (currently supported by SK700)
      int getStatus()
      查询当前打印状态
      Check current printer status.
      void init()
      打印初始化
      Printer Initialization
      void invert(boolean isInvert)
      设置反显打印,缺省为正常打印。
      Invert Pinter Setting,default to normal printing.
      boolean isLowPowerPrintEnabled()
      检查低功率打印是否开启
      Check whether low-power printing is enabled
      void leftIndent(int indent)
      设置字符打印左边界
      默认边界为0
      当输入的参数超过最大值时,按照最大值设置
      Set character printing left boundary.
      void presetCutPaper(int mode)
      设置切纸模式。打印完成后立刻切纸。提示: 请在start()前调用该方法。
      Set the cutting mode.
      void print(android.graphics.Bitmap bitmap, int cutMode, IPrinter.IPinterListener listener)
      直接打印Bitmap,异步封装接口 (不能与除了setGray(int)之外的Printer接口直接混用)。print前后会自动init,但灰度值会保留
      Print bitmap directly,asynchronous encapsulation interface(Cannot mix with the Printer interface except (int)).Init automatically print before and after,but the grey value will be saved.
      void print(android.graphics.Bitmap bitmap, IPrinter.IPinterListener listener)
      直接打印Bitmap,异步封装接口 (不能与除了setGray(int)之外的Printer接口直接混用)。print前后会自动init,但灰度值会保留
      Print bitmap directly,asynchronous encapsulation interface(Cannot mix with the Printer interface except (int)).Init automatically print before and after,but the grey value will be saved.
      void printBitmap(android.graphics.Bitmap bitmap)
      打印图片
      Print bitmap
      void printBitmapWithMonoThreshold(android.graphics.Bitmap bitmap, int grayThreshold)
      打印图片
      Print bitmap
      void printColorBitmap(android.graphics.Bitmap bitmap)
      打印双色位图
      Print a two-color bitmap
      void printColorBitmapWithMonoThreshold(android.graphics.Bitmap bitmap, int grayThreshold)
      打印双色位图
      Print a two-color bitmap
      void printStr(java.lang.String str, java.lang.String charset)
      打印字符串
      支持打印串中出现‘\n‘[换行]、‘\f‘[换页]控制字符; 如果打印数据包过长,则程序将溢出; 如果打印字符串超出打印范围,将自动换行后继续打印; 缓冲区最大为2048字节。 将str存入打印缓冲区,在调用start()后,按照写入缓冲区的顺序,开始打印缓冲区里的数据。
      Support '\n' (new line) and '\f' (new page) control characters; If the printing data package is too long, then the printing program will overflow; If the string is longer than the current printing line, change line automatically and continue printing. The maximum buffer size is 2048 bytes. Store str in printing buffer, and print data in printing buffer in sequence after calling start().
      void setAlignMode(short alignMode)
      设置打印对齐模式
      Set print alignment mode
      void setColorGray(int blackLevel, int colorLevel)
      设置彩色打印的黑值跟彩色值
      Set the black value and color value for color printing
      void setFontPath(java.lang.String fontPath)
      设置打印机字体
      set ptinter font path.
      void setGray(int level)
      设置打印黑度等级
      Set printing gray level.
      boolean setPrinterSize(int size)
      设置打印纸尺寸(目前SK700支持)注意:设置后需重启设备才能生效
      Set the paper size (currently supported by SK700) Note: After setting, you need to restart the device to take effect.
      void spaceSet(byte wordSpace, byte lineSpace)
      设置打印字间距、行间距。
      在对打印机有效设置后将一直有效,直至下次设置或调用init() 打印机的默认字间距为0 打印机的默认行间距热敏为0,针打为2 打印机的行间距极大值为255
      打印机的字间距极大值为255,针式打印机最大间距为60
      Settings will be valid until they are set again or init() is called; Printing character space is 0 by default; Printing line space is 0 for thermal and 2 for stylus printer; The maximum line space can be 255; The maximum character space can be 255.
      int start()
      启动打印机,将缓冲区里的数据打印出来, 此接口为同步接口
      在调用该函数后,打印机将进行打印,直到打印结束后才返回; 在打印结束后,该函数会返回打印状态,因此可不必再查询打印状态; 如果打印机在成功完成打印任务后,再次调用该函数,则会将单据重打一遍。 使用上应遵循公式:每行的点数 = 字符的高度 + 行距。总的点数 =每行的点数 * 行数 。总的点数要小于30000,默认字符高度是24。
      Start printer and prints data in buffer.This is synchronous interface.
      int start(IPrinListener listener)
      启动打印机,将缓冲区里的数据打印出来, 同时监听当前打印的行数,此接口为同步接口
      在调用该函数后,打印机将进行打印,直到打印结束后才返回; 在打印结束后,该函数会返回打印状态,因此可不必再查询打印状态; 如果打印机在成功完成打印任务后,再次调用该函数,则会将单据重打一遍。 使用上应遵循公式:每行的点数 = 字符的高度 + 行距。总的点数 =每行的点数 * 行数 。总的点数要小于30000,默认字符高度是24。
      Start printer and prints data in buffer,while monitoring the number of lines currently printed,This is synchronous interface.
      void step(int pixel)
      让打印机走纸pixel个像素点
      如果pixel为正数则进纸,pixel为负数则退纸,pixel为0时无动作。 该指令为一次打印动作,即在执行后即刻失效。 对于针式打印机,pixel小于-255或者大于255,该函数不做任何动作
      If the pixel value is positive, then the paper will feed forward.
    • Method Detail

      • spaceSet

        void spaceSet(byte wordSpace,
                      byte lineSpace)
               throws PrinterDevException
        设置打印字间距、行间距。
        • 在对打印机有效设置后将一直有效,直至下次设置或调用init()
        • 打印机的默认字间距为0
        • 打印机的默认行间距热敏为0,针打为2
        • 打印机的行间距极大值为255
        • 打印机的字间距极大值为255,针式打印机最大间距为60
        • Settings will be valid until they are set again or init() is called;
        • Printing character space is 0 by default;
        • Printing line space is 0 for thermal and 2 for stylus printer;
        • The maximum line space can be 255;
        • The maximum character space can be 255. (stylus printer is 60);
        Parameters:
        wordSpace -
        字间距[像素点]
        Character space [pixels]
        lineSpace -
        行间距[像素点]
        Line space [pixels]
        Throws:
        PrinterDevException
      • step

        void step(int pixel)
           throws PrinterDevException
        让打印机走纸pixel个像素点
        • 如果pixel为正数则进纸,pixel为负数则退纸,pixel为0时无动作。
        • 该指令为一次打印动作,即在执行后即刻失效。
        • 对于针式打印机,pixel小于-255或者大于255,该函数不做任何动作
        • If the pixel value is positive, then the paper will feed forward. If it is negative, then feed backward. If it is 0,then no action.
        • This is a one time action.
        • For the stylus printer, there is no action when pixel less than -255 or pixel greater than 255.
        Parameters:
        pixel -
        像素点个数
        number of pixels
        Throws:
        PrinterDevException
      • printStr

        void printStr(java.lang.String str,
                      java.lang.String charset)
               throws PrinterDevException
        打印字符串
        • 支持打印串中出现‘\n‘[换行]、‘\f‘[换页]控制字符;
        • 如果打印数据包过长,则程序将溢出;
        • 如果打印字符串超出打印范围,将自动换行后继续打印;
        • 缓冲区最大为2048字节。
        • 将str存入打印缓冲区,在调用start()后,按照写入缓冲区的顺序,开始打印缓冲区里的数据。
        • Support '\n' (new line) and '\f' (new page) control characters;
        • If the printing data package is too long, then the printing program will overflow;
        • If the string is longer than the current printing line, change line automatically and continue printing.
        • The maximum buffer size is 2048 bytes.
        • Store str in printing buffer, and print data in printing buffer in sequence after calling start().
        Parameters:
        str -
        打印字符串
        print string
        charset -
        Str字符集,为null时,默认为UTF-8字符集
        When character set is NULL,default to UTF-8.
        Throws:
        PrinterDevException
      • start

        int start()
           throws PrinterDevException
        启动打印机,将缓冲区里的数据打印出来, 此接口为同步接口
        • 在调用该函数后,打印机将进行打印,直到打印结束后才返回;
        • 在打印结束后,该函数会返回打印状态,因此可不必再查询打印状态;
        • 如果打印机在成功完成打印任务后,再次调用该函数,则会将单据重打一遍。
        • 使用上应遵循公式:每行的点数 = 字符的高度 + 行距。总的点数 =每行的点数 * 行数 。总的点数要小于30000,默认字符高度是24。
        Start printer and prints data in buffer.This is synchronous interface.
        • After calling this function, the printer will perform the printing task and return after completed the whole printing task.
        • After completed the whole printing task, this function will return the printer status in return value. Therefore the check printer status is not required.
        • If the printing process is completed, recalling this function will reprint the slip.
        • Use should follow the formula: the number of points per line = the height of the character + the line space. Total number of points = number of points per row * number of rows.The total number of points should be less than 30,000, and the default character height is 24.
        Returns:
        • 0: 正常
        • 1: 打印机忙
        • 2: 打印机缺纸
        • 3: 打印数据包格式错
        • 4: 打印机故障
        • 8: 打印机过热
        • 9: 打印机电压过低
        • -16:打印未完成
        • -6:切刀异常(支持E500,E800)
        • -5:开盖错误(支持E500,E800)
        • -4:打印机未安装字库
        • -2:数据包过长
        • 0- Success
        • 1- Printer is busy
        • 2- Out of paper
        • 3- The format of print data packet error
        • 4- Printer malfunctions
        • 8- Printer over heats
        • 9- Printer voltage is too low
        • -16- Printing is unfinished
        • -6: cut jam error(only support:E500,E800)
        • -5: cover open error(only support:E500,E800)
        • -4- The printer has not installed font library
        • -2- Data package is too long
        Throws:
        PrinterDevException
      • getStatus

        int getStatus()
               throws PrinterDevException
        查询当前打印状态
        Check current printer status.
        Returns:
        • 0: 正常
        • 1: 打印机忙
        • 2: 打印机缺纸
        • 3: 打印数据包格式错
        • 4: 打印机故障
        • 8: 打印机过热
        • 9: 打印机电压过低
        • -16:打印未完成
        • -6:切刀异常(支持E500,E800)
        • -5:开盖错误(支持E500,E800,SK600,SK800)
        • -4:打印机未安装字库
        • -2:数据包过长
        • 0- Success
        • 1- Printer is busy
        • 2- Out of paper
        • 3- The format of print data packet error
        • 4- Printer malfunctions
        • 8- Printer over heats
        • 9- Printer voltage is too low
        • -16- Printing is unfinished
        • -6: cut jam error(only support:E500,E800)
        • -5: cover open error(only support:E500,E800,SK600,SK800)
        • -4- The printer has not installed font library
        • -2- Data package is too long
        Throws:
        PrinterDevException
      • leftIndent

        void leftIndent(int indent)
                 throws PrinterDevException
        设置字符打印左边界
        默认边界为0
        当输入的参数超过最大值时,按照最大值设置
        Set character printing left boundary. Default value is 0. If the input value exceed the maximum, the maximum one will be used.
        Parameters:
        indent -
        左边界空白像素点,范围:0~300
        0~300 Vacant dots in left boundary, range: 0~300
        Throws:
        PrinterDevException
      • setGray

        void setGray(int level)
              throws PrinterDevException
        设置打印黑度等级
        Set printing gray level.
        Parameters:
        level -
        • Level=0 保留
        • Level=1 缺省黑度,即普通打印单
        • Level=2 保留
        • Level=3 双层热敏打印
        • Level=4 双层热敏打印,比3的黑度更高
        • Level=[50~500] 黑度按照缺省黑度百分比进行设置,如50是把黑度设置为默认值的50%,500则把黑度设置为500%
        • Level=0 -Reserved
        • Level=1 -Default level, normal print slip
        • Level=2 -Reserved
        • Level=3 -Two-layer thermal printing
        • Level=4 -Two-layer thermal printing, higher gray level than 3
        • Level=[50~500] -Gray level is set according to percentage of default value. If it is 50, then set gray level to be 50% of default value; If it is 500, then set grey level to be 500% of default value.
        Throws:
        PrinterDevException
      • doubleWidth

        void doubleWidth(boolean isAscDouble,
                         boolean isLocalDouble)
                  throws PrinterDevException
        设置打印字体宽度,可在基本字体上实现双倍宽度的打印
        Set printing font which is based on base font to double width.
        Parameters:
        isAscDouble -
        单内码字体是否倍宽
        If the single coding font is double width or not.
        isLocalDouble -
        多内码字体是否倍宽
        If the multi coding font is double width or not.
        Throws:
        PrinterDevException
      • doubleHeight

        void doubleHeight(boolean isAscDouble,
                          boolean isLocalDouble)
                   throws PrinterDevException
        设置打印字体高度,可在基本字体上实现双倍高度的打印。
        Set printing font which is based on base font to double height.
        Parameters:
        isAscDouble -
        单内码字体是否倍高
        If the single coding font is double height or not.
        isLocalDouble -
        多内码字体是否倍高
        If the multi coding font is double height or not.
        Throws:
        PrinterDevException
      • invert

        void invert(boolean isInvert)
             throws PrinterDevException
        设置反显打印,缺省为正常打印。
        Invert Pinter Setting,default to normal printing.
        Parameters:
        isInvert -
        • true-反显
        • false-正常
        • true -Invert
        • false -Normal
        Throws:
        PrinterDevException
      • cutPaper

        void cutPaper(int mode)
               throws PrinterDevException
        切纸
        cut paper
        Parameters:
        mode -
        mode =0时, 表示全部切纸 ;mode =1时, 表示部分切纸
        mode =0: full paper cut;mode =1:Partial paper cutting
        Throws:
        PrinterDevException
      • getCutMode

        int getCutMode()
                throws PrinterDevException
        获取当前切纸模式
        get cut mode
        Returns:
        • 0:仅支持全切
        • 1:仅支持半切
        • 2:支持全切 和 半切
        • -1:无切刀,不支持切纸
        • 0:Only support full paper cut
        • 1:Only support partial paper cutting
        • 2:support partial paper and full paper cutting
        • -1:No cutting knife,not support
        Throws:
        PrinterDevException
      • print

        void print(android.graphics.Bitmap bitmap,
                   IPrinter.IPinterListener listener)
        直接打印Bitmap,异步封装接口 (不能与除了setGray(int)之外的Printer接口直接混用)。print前后会自动init,但灰度值会保留
        Print bitmap directly,asynchronous encapsulation interface(Cannot mix with the Printer interface except (int)).Init automatically print before and after,but the grey value will be saved.
        Parameters:
        bitmap -
        位图,不能为null
        bitmap,can't be null
        listener -
        监听器(IPrinter.IPinterListener),为null时直接打印无结果回调
        listener( IPrinter.IPinterListener ),direct print without result callback for null
      • print

        void print(android.graphics.Bitmap bitmap,
                   int cutMode,
                   IPrinter.IPinterListener listener)
        直接打印Bitmap,异步封装接口 (不能与除了setGray(int)之外的Printer接口直接混用)。print前后会自动init,但灰度值会保留
        Print bitmap directly,asynchronous encapsulation interface(Cannot mix with the Printer interface except (int)).Init automatically print before and after,but the grey value will be saved.
        Parameters:
        bitmap -
        位图,不能为null
        bitmap,can't be null
        cutMode -
        切纸模式, mode =0时, 表示全部切纸 ;mode =1时, 表示部分切纸
        cut mode,mode =0: full paper cut;mode =1:Partial paper cutting
        listener -
        监听器(IPrinter.IPinterListener),为null时直接打印无结果回调
        listener( IPrinter.IPinterListener ),direct print without result callback for null
        Since:
        V2.03.00
      • presetCutPaper

        void presetCutPaper(int mode)
                     throws PrinterDevException
        设置切纸模式。打印完成后立刻切纸。提示: 请在start()前调用该方法。
        Set the cutting mode. Cut the paper immediately after printing. Tip: Please call this method before start().
        Parameters:
        mode -
        切纸模式。
        • -1: 不切纸。
        • 0: 全部切纸。
        • 1: 部分切纸。
        • -1: Do not cut paper.
        • 0: Full paper cut.
        • 1: Partial paper cut.
        Throws:
        PrinterDevException - PrinterDevException
        Since:
        V3.22.00
      • setPrinterSize

        boolean setPrinterSize(int size)
                        throws PrinterDevException
        设置打印纸尺寸(目前SK700支持)注意:设置后需重启设备才能生效
        Set the paper size (currently supported by SK700) Note: After setting, you need to restart the device to take effect.
        Parameters:
        size -
        打印纸尺寸(支持2寸或3寸)
        Printing paper size (support 2 inches or 3 inches)
        Returns:
        true: 设置成功, false: 设置失败
        true: set successfully, false: set failed
        Throws:
        PrinterDevException
      • isLowPowerPrintEnabled

        boolean isLowPowerPrintEnabled()
                                throws PrinterDevException
        检查低功率打印是否开启
        Check whether low-power printing is enabled
        Returns:
        true:低功率打印已开启 false:低功率打印已关闭
        true: Low-power printing is enabled. false: low-power printing is disabled
        Throws:
        PrinterDevException
      • enableLowPowerPrint

        void enableLowPowerPrint(boolean enable)
                          throws PrinterDevException
        开启或关闭低功率打印
        Enable or disable low-power printing
        Parameters:
        enable -
        true:开启低功率打印功能 false:关闭低功率打印功能
        true: enables low-power printing. false: Disables low-power printing
        Throws:
        PrinterDevException
      • setAlignMode

        void setAlignMode(short alignMode)
                   throws PrinterDevException
        设置打印对齐模式
        Set print alignment mode
        Parameters:
        alignMode -
        打印对齐模式,0为左对齐,1为居中对齐,2为右对齐
        Print alignment mode, 0 is left alignment, 1 is center alignment, 2 is right alignment
        Throws:
        PrinterDevException
      • printColorBitmapWithMonoThreshold

        void printColorBitmapWithMonoThreshold(android.graphics.Bitmap bitmap,
                                               int grayThreshold)
                                        throws PrinterDevException
        打印双色位图
        Print a two-color bitmap
        Parameters:
        bitmap -
        打印双色位图的大小限制:如果位图的宽度超过打印机的限制,将会裁剪图片的右边
        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
        grayThreshold -
        图像灰度阀值 0-255
        Gray threshold . between 0 and 255
        Throws:
        PrinterDevException
        Since:
        V4.09.00
      • printColorBitmap

        void printColorBitmap(android.graphics.Bitmap bitmap)
                       throws PrinterDevException
        打印双色位图
        Print a two-color bitmap
        Parameters:
        bitmap -
        打印双色位图的大小限制:如果位图的宽度超过打印机的限制,将会裁剪图片的右边
        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
        Throws:
        PrinterDevException
        Since:
        V4.09.00
      • setColorGray

        void setColorGray(int blackLevel,
                          int colorLevel)
                   throws PrinterDevException
        设置彩色打印的黑值跟彩色值
        Set the black value and color value for color printing
        Parameters:
        blackLevel -
        黑值
        Black number
        colorLevel -
        彩色值
        Chroma value
        Throws:
        PrinterDevException
        Since:
        V4.09.00
      • start

        int start(IPrinListener listener)
           throws PrinterDevException
        启动打印机,将缓冲区里的数据打印出来, 同时监听当前打印的行数,此接口为同步接口
        • 在调用该函数后,打印机将进行打印,直到打印结束后才返回;
        • 在打印结束后,该函数会返回打印状态,因此可不必再查询打印状态;
        • 如果打印机在成功完成打印任务后,再次调用该函数,则会将单据重打一遍。
        • 使用上应遵循公式:每行的点数 = 字符的高度 + 行距。总的点数 =每行的点数 * 行数 。总的点数要小于30000,默认字符高度是24。
        Start printer and prints data in buffer,while monitoring the number of lines currently printed,This is synchronous interface.
        • After calling this function, the printer will perform the printing task and return after completed the whole printing task.
        • After completed the whole printing task, this function will return the printer status in return value. Therefore the check printer status is not required.
        • If the printing process is completed, recalling this function will reprint the slip.
        • Use should follow the formula: the number of points per line = the height of the character + the line space. Total number of points = number of points per row * number of rows.The total number of points should be less than 30,000, and the default character height is 24.
        Returns:
        • 0: 正常
        • 1: 打印机忙
        • 2: 打印机缺纸
        • 3: 打印数据包格式错
        • 4: 打印机故障
        • 8: 打印机过热
        • 9: 打印机电压过低
        • -16:打印未完成
        • -6:切刀异常(支持E500,E800)
        • -5:开盖错误(支持E500,E800)
        • -4:打印机未安装字库
        • -2:数据包过长
        • 0- Success
        • 1- Printer is busy
        • 2- Out of paper
        • 3- The format of print data packet error
        • 4- Printer malfunctions
        • 8- Printer over heats
        • 9- Printer voltage is too low
        • -16- Printing is unfinished
        • -6: cut jam error(only support:E500,E800)
        • -5: cover open error(only support:E500,E800)
        • -4- The printer has not installed font library
        • -2- Data package is too long
        Throws:
        PrinterDevException
        Since:
        V4.18.00