Ejemplo n.º 1
0
def printComplexReceiptVoiceSupport():
    # <BR>:换行符(同一行有闭合标签(如 </C>)则应放到闭合标签前面, 连续两个换行符<BR><BR>可以表示加一空行)
    #  <L></L>:左对齐
    #  <C></C>:居中对齐
    #  <R></R>:右对齐
    #  注意:同一行内容不能使用多种对齐方式,可通过补空格方式自定义对齐样式。
    #       58mm的机器,一行打印16个汉字,32个字母
    #       80mm的机器,一行打印24个汉字,48个字母
    #
    #  <N></N>:字体正常大小
    #  <HB></HB>:字体变高一倍
    #  <WB></WB>:字体变宽一倍
    #  <B></B>:字体放大一倍
    #  <CB></CB>:字体放大一倍居中
    #  <HB2></HB2>:字体变高二倍
    #  <WB2></WB2>:字体变宽二倍
    #  <B2></B2>:字体放大二倍
    #  <BOLD></BOLD>:字体加粗
    #  <LOGO></LOGO>:LOGO图片(标签内容是图片Base64格式字符串, 暂未开放)
    #  <QR></QR>:二维码(标签内容是二维码值, 最大不能超过256个字符, 单个订单最多只能打印一个二维码)。
    #             二维码宽度设置:可以通过 <QR> 标签名称自定义,如 <QR180> 表示宽度为180,相应的闭合标签 </QR>
    #             不需要指定宽度。<QR> 标签不指定宽度默认为110,最小值为90,最大值为180
    #  <BARCODE></BARCODE>:条形码(标签内容是条形码值)

    printContent = ""

    printContent = printContent + "<C>" + "<B>芯烨云小票</B>" + "<BR></C>"
    printContent = printContent + "<BR>"

    printContent = printContent + "菜名" + " " * 16 + "数量" + " " * 2 + "单价" + " " * 2 \
                   + "<BR>"
    printContent = printContent + "-" * 32 + "<BR>"
    printContent = printContent + formatter.formatPrintOrderItem(
        "可乐鸡翅", 2, 9.99)
    printContent = printContent + formatter.formatPrintOrderItem(
        "水煮鱼特辣", 1, 108.0)
    printContent = printContent + formatter.formatPrintOrderItem(
        "豪华版超级无敌龙虾炒饭", 1, 99.9)
    printContent = printContent + formatter.formatPrintOrderItem(
        "炭烤鳕鱼", 5, 19.99)
    printContent = printContent + "-" * 32 + "<BR>"
    printContent = printContent + "<R>" + "合计:" + "327.83" + "元" + "<BR></R>"

    printContent = printContent + "<BR>"
    printContent = printContent + "<L>" \
                   + "客户地址:" + "珠海市香洲区xx路xx号" + "<BR>" \
                   + "客户电话:" + "1363*****88" + "<BR>" \
                   + "下单时间:" + "2020-9-9 15:07:57" + "<BR>" \
                   + "备注:" + "少放辣 不吃香菜" + "<BR>"

    printContent = printContent + "<C>" \
                   + "<QR>https:#www.xpyun.net</QR>" \
                   + "</C>"

    request = model.PrintRequest(USER_NAME, USER_KEY)
    request.user = USER_NAME
    request.userKey = USER_KEY

    # *必填*:打印机编号
    request.sn = OK_PRINTER_SN

    request.generateSign()

    # *必填*:打印内容,不能超过12K
    request.content = printContent

    # 打印份数,默认为1
    request.copies = 1

    # 打印模式:
    # 值为 0 或不指定则会检查打印机是否在线,如果不在线 则不生成打印订单,直接返回设备不在线状态码;如果在线则生成打印订单,并返回打印订单号。
    # 值为 1不检查打印机是否在线,直接生成打印订单,并返回打印订单号。如果打印机不在线,订单将缓存在打印队列中,打印机正常在线时会自动打印。
    request.mode = 0

    # 支付方式:
    # 取值范围41~55:
    # 支付宝 41、微信 42、云支付 43、银联刷卡 44、银联支付 45、会员卡消费 46、会员卡充值 47、翼支付 48、成功收款 49、嘉联支付 50、壹钱包 51、京东支付 52、快钱支付 53、威支付 54、享钱支付 55
    # 仅用于支持金额播报的芯烨云打印机。
    request.payType = 41

    # 支付与否:
    # 取值范围59~61:
    # 退款 59 到账 60 消费 61。
    # 仅用于支持金额播报的芯烨云打印机。
    request.payMode = 60

    # 支付金额:
    # 最多允许保留2位小数。
    # 仅用于支持金额播报的芯烨云打印机。
    request.money = 20.15

    result = service.xpYunPrint(request)
    print(result.httpStatusCode)
    print(result.content)
    print(result.content.code)
    print(result.content.msg)

    # data:正确返回订单编号
    print(result.content.data)
Ejemplo n.º 2
0
def printFontAlign():
    # <BR>:换行符(同一行有闭合标签(如 </C>)则应放到闭合标签前面, 连续两个换行符<BR><BR>可以表示加一空行)
    #  <L></L>:左对齐
    #  <C></C>:居中对齐
    #  <R></R>:右对齐
    #  注意:同一行内容不能使用多种对齐方式,可通过补空格方式自定义对齐样式。
    #       58mm的机器,一行打印16个汉字,32个字母
    #       80mm的机器,一行打印24个汉字,48个字母
    #
    #  <N></N>:字体正常大小
    #  <HB></HB>:字体变高一倍
    #  <WB></WB>:字体变宽一倍
    #  <B></B>:字体放大一倍
    #  <CB></CB>:字体放大一倍居中
    #  <HB2></HB2>:字体变高二倍
    #  <WB2></WB2>:字体变宽二倍
    #  <B2></B2>:字体放大二倍
    #  <BOLD></BOLD>:字体加粗
    #  <LOGO></LOGO>:LOGO图片(标签内容是图片Base64格式字符串, 暂未开放)
    #  <QR></QR>:二维码(标签内容是二维码值, 最大不能超过256个字符, 单个订单最多只能打印一个二维码)。
    #             二维码宽度设置:可以通过 <QR> 标签名称自定义,如 <QR180> 表示宽度为180,相应的闭合标签 </QR>
    #             不需要指定宽度。<QR> 标签不指定宽度默认为110,最小值为90,最大值为180
    #  <BARCODE></BARCODE>:条形码(标签内容是条形码值)

    printContent = '''不加标签:默认字体大小<BR>
<BR>
L标签:<L>左对齐<BR></L>
<BR>
R标签:<R>右对齐<BR></R>
<BR>
C标签:<C>居中对齐<BR></C>
<BR>
N标签:<N>字体正常大小<BR></N>
<BR>
HB标签:<HB>字体变高一倍<BR></HB>
<BR>
WB标签:<WB>字体变宽一倍<BR></WB>
<BR>
B标签:<B>字体放大一倍<BR></B>
<BR>
HB2标签:<HB2>字体变高二倍<BR></HB2>
<BR>
WB2标签:<WB2>字体变宽二倍<BR></WB2>
<BR>
B2标签:<B2>字体放大二倍<BR></B2>
<BR>
BOLD标签:<BOLD>字体加粗<BR></BOLD>'''

    printContent = printContent + '<BR>'
    # 嵌套使用对齐和字体
    printContent = printContent + '<C>嵌套使用:<BOLD>居中加粗</BOLD><BR></C>'

    # 打印条形码和二维码
    printContent = printContent + '<BR>'
    printContent = printContent + '<C><BARCODE>9884822189</BARCODE></C>'
    printContent = printContent + '<C><QR>https:#www.xpyun.net</QR></C>'

    request = model.PrintRequest(USER_NAME, USER_KEY)

    # *必填*:打印机编号
    request.sn = OK_PRINTER_SN
    request.generateSign()

    # *必填*:打印内容,不能超过12K
    request.content = printContent

    # 打印份数,默认为1
    request.copies = 1

    # 打印模式:
    # 值为 0 或不指定则会检查打印机是否在线,如果不在线 则不生成打印订单,直接返回设备不在线状态码;如果在线则生成打印订单,并返回打印订单号。
    # 值为 1不检查打印机是否在线,直接生成打印订单,并返回打印订单号。如果打印机不在线,订单将缓存在打印队列中,打印机正常在线时会自动打印。
    request.mode = 0

    result = service.xpYunPrint(request)
    print(result.httpStatusCode)
    print(result.content)
    print(result.content.code)
    print(result.content.msg)

    print(result.content.data)
Ejemplo n.º 3
0
def printComplexReceipt():
    # <BR>:换行符(同一行有闭合标签(如 </C>)则应放到闭合标签前面, 连续两个换行符<BR><BR>可以表示加一空行)
    #  <L></L>:左对齐
    #  <C></C>:居中对齐
    #  <R></R>:右对齐
    #  注意:同一行内容不能使用多种对齐方式,可通过补空格方式自定义对齐样式。
    #       58mm的机器,一行打印16个汉字,32个字母
    #       80mm的机器,一行打印24个汉字,48个字母
    #
    #  <N></N>:字体正常大小
    #  <HB></HB>:字体变高一倍
    #  <WB></WB>:字体变宽一倍
    #  <B></B>:字体放大一倍
    #  <CB></CB>:字体放大一倍居中
    #  <HB2></HB2>:字体变高二倍
    #  <WB2></WB2>:字体变宽二倍
    #  <B2></B2>:字体放大二倍
    #  <BOLD></BOLD>:字体加粗
    #  <LOGO></LOGO>:LOGO图片(标签内容是图片Base64格式字符串, 暂未开放)
    #  <QR></QR>:二维码(标签内容是二维码值, 最大不能超过256个字符, 单个订单最多只能打印一个二维码)。
    #             二维码宽度设置:可以通过 <QR> 标签名称自定义,如 <QR180> 表示宽度为180,相应的闭合标签 </QR>
    #             不需要指定宽度。<QR> 标签不指定宽度默认为110,最小值为90,最大值为180
    #  <BARCODE></BARCODE>:条形码(标签内容是条形码值)

    printContent = ""

    printContent = printContent + "<C>" + "<B>芯烨云小票</B>" + "<BR></C>"
    printContent = printContent + "<BR>"

    printContent = printContent + "菜名" + " " * 16 + "数量" + " " * 2 + "单价" + " " * 2 + "<BR>"
    printContent = printContent + "-" * 32 + "<BR>"
    printContent = printContent + formatter.formatPrintOrderItem(
        "可乐鸡翅", 2, 9.99)
    printContent = printContent + formatter.formatPrintOrderItem(
        "水煮鱼特辣", 1, 108.0)
    printContent = printContent + formatter.formatPrintOrderItem(
        "豪华版超级无敌龙虾炒饭", 1, 99.9)
    printContent = printContent + formatter.formatPrintOrderItem(
        "炭烤鳕鱼", 5, 19.99)
    printContent = printContent + "-" * 32 + "<BR>"
    printContent = printContent + "<R>" + "合计:" + "327.83" + "元" + "<BR></R>"

    printContent = printContent + "<BR>"
    printContent = printContent + "<L>" \
                   + "客户地址:" + "珠海市香洲区xx路xx号" + "<BR>" \
                   + "客户电话:" + "1363*****88" + "<BR>" \
                   + "下单时间:" + "2020-9-9 15:07:57" + "<BR>" \
                   + "备注:" + "少放辣 不吃香菜" + "<BR>"

    printContent = printContent + "<C>" \
                   + "<QR>https:#www.xpyun.net</QR>" \
                   + "</C>"

    request = model.PrintRequest(USER_NAME, USER_KEY)
    request.user = USER_NAME
    request.userKey = USER_KEY

    # *必填*:打印机编号
    request.sn = OK_PRINTER_SN

    request.generateSign()

    # *必填*:打印内容,不能超过12K
    request.content = printContent

    # 打印份数,默认为1
    request.copies = 1

    result = service.xpYunPrint(request)
    print(result.httpStatusCode)
    print(result.content)
    print(result.content.code)
    print(result.content.msg)

    # data:正确返回订单编号
    print(result.content.data)
Ejemplo n.º 4
0
def printFontAlignVoiceSupport():
    # <BR>:换行符(同一行有闭合标签(如 </C>)则应放到闭合标签前面, 连续两个换行符<BR><BR>可以表示加一空行)
    #  <L></L>:左对齐
    #  <C></C>:居中对齐
    #  <R></R>:右对齐
    #  注意:同一行内容不能使用多种对齐方式,可通过补空格方式自定义对齐样式。
    #       58mm的机器,一行打印16个汉字,32个字母
    #       80mm的机器,一行打印24个汉字,48个字母
    #
    #  <N></N>:字体正常大小
    #  <HB></HB>:字体变高一倍
    #  <WB></WB>:字体变宽一倍
    #  <B></B>:字体放大一倍
    #  <CB></CB>:字体放大一倍居中
    #  <HB2></HB2>:字体变高二倍
    #  <WB2></WB2>:字体变宽二倍
    #  <B2></B2>:字体放大二倍
    #  <BOLD></BOLD>:字体加粗
    #  <LOGO></LOGO>:LOGO图片(标签内容是图片Base64格式字符串, 暂未开放)
    #  <QR></QR>:二维码(标签内容是二维码值, 最大不能超过256个字符, 单个订单最多只能打印一个二维码)。
    #             二维码宽度设置:可以通过 <QR> 标签名称自定义,如 <QR180> 表示宽度为180,相应的闭合标签 </QR>
    #             不需要指定宽度。<QR> 标签不指定宽度默认为110,最小值为90,最大值为180
    #  <BARCODE></BARCODE>:条形码(标签内容是条形码值)

    printContent = '''不加标签:默认字体大小<BR>
<BR>
L标签:<L>左对齐<BR></L>
<BR>
R标签:<R>右对齐<BR></R>
<BR>
C标签:<C>居中对齐<BR></C>
<BR>
N标签:<N>字体正常大小<BR></N>
<BR>
HB标签:<HB>字体变高一倍<BR></HB>
<BR>
WB标签:<WB>字体变宽一倍<BR></WB>
<BR>
B标签:<B>字体放大一倍<BR></B>
<BR>
HB2标签:<HB2>字体变高二倍<BR></HB2>
<BR>
WB2标签:<WB2>字体变宽二倍<BR></WB2>
<BR>
B2标签:<B2>字体放大二倍<BR></B2>
<BR>
BOLD标签:<BOLD>字体加粗<BR></BOLD>'''

    printContent = printContent + '<BR>'
    # 嵌套使用对齐和字体
    printContent = printContent + '<C>嵌套使用:<BOLD>居中加粗</BOLD><BR></C>'

    # 打印条形码和二维码
    printContent = printContent + '<BR>'
    printContent = printContent + '<C><BARCODE>9884822189</BARCODE></C>'
    printContent = printContent + '<C><QR>https:#www.xpyun.net</QR></C>'

    request = model.PrintRequest(USER_NAME, USER_KEY)

    # *必填*:打印机编号
    request.sn = OK_PRINTER_SN
    request.generateSign()

    # *必填*:打印内容,不能超过12K
    request.content = printContent

    # 打印份数,默认为1
    request.copies = 1

    # 打印模式:
    # 值为 0 或不指定则会检查打印机是否在线,如果不在线 则不生成打印订单,直接返回设备不在线状态码;如果在线则生成打印订单,并返回打印订单号。
    # 值为 1不检查打印机是否在线,直接生成打印订单,并返回打印订单号。如果打印机不在线,订单将缓存在打印队列中,打印机正常在线时会自动打印。
    request.mode = 0

    # 支付方式:
    # 取值范围41~55:
    # 支付宝 41、微信 42、云支付 43、银联刷卡 44、银联支付 45、会员卡消费 46、会员卡充值 47、翼支付 48、成功收款 49、嘉联支付 50、壹钱包 51、京东支付 52、快钱支付 53、威支付 54、享钱支付 55
    # 仅用于支持金额播报的芯烨云打印机。
    request.payType = 41

    # 支付与否:
    # 取值范围59~61:
    # 退款 59 到账 60 消费 61。
    # 仅用于支持金额播报的芯烨云打印机。
    request.payMode = 60

    # 支付金额:
    # 最多允许保留2位小数。
    # 仅用于支持金额播报的芯烨云打印机。
    request.money = 20.15

    result = service.xpYunPrint(request)
    print(result.httpStatusCode)
    print(result.content)
    print(result.content.code)
    print(result.content.msg)

    # data:正确返回订单编号
    print(result.content.data)
Ejemplo n.º 5
0
def printComplexReceiptVoiceSupport():
    # 〈BR〉: line break (if there is a closing tag (e.g. 〈/C〉), it should be placed in front of the closing tag, two consecutive line breaks indicate adding a null string.
    # 〈L〉〈/L〉: left aligned
    # 〈C〉〈/C〉: center aligned
    # 〈R〉〈/R〉: right aligned
    # 〈N〉〈/C〉: normal font size
    # 〈HB〉〈/HB〉: double font in height
    # 〈WB〉〈/WB〉: double font in width
    # 〈B〉〈/B〉: double font in size
    # 〈CB〉〈/CB〉: double font in size centred
    # 〈HB2〉〈/HB2〉: three times the font in height
    # 〈WB2〉〈/WB2〉: three times the font in width
    # 〈B2〉〈/B2〉: three times the font in size
    # 〈BOLD〉〈/BOLD〉: bold font
    # 〈LOGO〉〈/LOGO〉: logo (the tag content is a character string in Base64 format, temporarily not opened)
    # 〈OR〉〈/QR〉: QR code (the tag content is a value of QR code, which cannot exceed 256 characters)
    # 〈BARCODE〉〈/BARCODE〉: barcode (the content is a value of barcode)
    # 〈CUT〉: cutter command (active paper cutting, only valid for cutter printer. Note: the print order of cutter printer has a cutter instruction by default in the end.)

    printContent = ""

    printContent = printContent + "<C>" + "<B>xpyun receipt</B>" + "<BR></C>"
    printContent = printContent + "<BR>"

    printContent = printContent + "name" + " " * 16 + "count" + " " * 2 + "price" + " " * 2 \
                   + "<BR>"
    printContent = printContent + "-" * 32 + "<BR>"
    printContent = printContent + formatter.formatPrintOrderItem("Stewed Ribs", 2, 9.99)
    printContent = printContent + formatter.formatPrintOrderItem("Boiled Fish", 1, 108.0)
    printContent = printContent + formatter.formatPrintOrderItem("Braised Codfish with Mushrooms", 1, 99.9)
    printContent = printContent + formatter.formatPrintOrderItem("Braised Squid", 5, 19.99)
    printContent = printContent + "-" * 32 + "<BR>"
    printContent = printContent + "<R>" + "total:" + "327.83" + "RMB" + "<BR></R>"

    printContent = printContent + "<BR>"
    printContent = printContent + "<L>" \
                   + "address:" + "Broadway, New York City" + "<BR>" \
                   + "phone:" + "1363*****88" + "<BR>" \
                   + "orderTime:" + "2020-9-9 15:07:57" + "<BR>" \
                   + "remarks:" + "Less spicy" + "<BR>"

    printContent = printContent + "<C>" \
                   + "<QR>https:#www.xpyun.net</QR>" \
                   + "</C>"

    request = model.PrintRequest(USER_NAME, USER_KEY)
    request.user = USER_NAME
    request.userKey = USER_KEY

    # *Required*: The serial number of the printer
    request.sn = OK_PRINTER_SN

    request.generateSign()

    # *Required*: The content to be printed can’t exceed 12288 bytes.
    request.content = printContent

    # The number of printed copies is 1 by default.
    request.copies = 1

    # Print mode:
    # If the value is 0 or not specified, it will check whether the printer is online. If not online, it will not generate a print order and directly return the status code of an offline device.
    # If online, it will generate a print order and return the print order number.If the value is 1, it will not check whether the printer is online, directly generate a print order and return the print order number.
    # If the printer is not online, the order will be cached in the print queue and will be printed automatically when the printer is normally online.
    request.mode = 0

    # payment method:
    # Value range 41~55:
    # Alipay 41, WeChat 42, Cloud Payment 43, UnionPay Swipe 44, UnionPay Payment 45, Member Card Consumption 46, Member Card Recharge 47, Yipay 48, Successful Collection 49, Jialian Payment 50, One Wallet 51, JD Pay 52, Quick money payment 53, Granville payment 54, Xiangqian payment 55
    # It is only used for Xinye cloud printers that support the amount broadcast
    request.payType = 41

    # Pay or not:
    # Value range 59~61:
    # Refund 59 to account 60 consumption 61.
    # It is only used for Xinye cloud printers that support the amount broadcast.
    request.payMode = 60

    # Payment amount:
    # Up to 2 decimal places are allowed.
    # It is only used for Xinye cloud printers that support the amount broadcast.
    request.money = 20.15

    result = service.xpYunPrint(request)
    print(result.httpStatusCode)
    print(result.content)
    print(result.content.code)
    print(result.content.msg)

    # resp.data: Return to order No. correctly
    print(result.content.data)
Ejemplo n.º 6
0
def printComplexReceipt():
    # 〈BR〉: line break (if there is a closing tag (e.g. 〈/C〉), it should be placed in front of the closing tag, two consecutive line breaks indicate adding a null string.
    # 〈L〉〈/L〉: left aligned
    # 〈C〉〈/C〉: center aligned
    # 〈R〉〈/R〉: right aligned
    # 〈N〉〈/C〉: normal font size
    # 〈HB〉〈/HB〉: double font in height
    # 〈WB〉〈/WB〉: double font in width
    # 〈B〉〈/B〉: double font in size
    # 〈CB〉〈/CB〉: double font in size centred
    # 〈HB2〉〈/HB2〉: three times the font in height
    # 〈WB2〉〈/WB2〉: three times the font in width
    # 〈B2〉〈/B2〉: three times the font in size
    # 〈BOLD〉〈/BOLD〉: bold font
    # 〈LOGO〉〈/LOGO〉: logo (the tag content is a character string in Base64 format, temporarily not opened)
    # 〈OR〉〈/QR〉: QR code (the tag content is a value of QR code, which cannot exceed 256 characters)
    # 〈BARCODE〉〈/BARCODE〉: barcode (the content is a value of barcode)
    # 〈CUT〉: cutter command (active paper cutting, only valid for cutter printer. Note: the print order of cutter printer has a cutter instruction by default in the end.)

    printContent = ""

    printContent = printContent + "<C>" + "<B>xpyun receipt</B>" + "<BR></C>"
    printContent = printContent + "<BR>"

    printContent = printContent + "name" + " " * 16 + "count" + " " * 2 + "price" + " " * 2 + "<BR>"
    printContent = printContent + "-" * 32 + "<BR>"
    printContent = printContent + formatter.formatPrintOrderItem("Stewed Ribs", 2, 9.99)
    printContent = printContent + formatter.formatPrintOrderItem("Boiled Fish", 1, 108.0)
    printContent = printContent + formatter.formatPrintOrderItem("Braised Codfish with Mushrooms", 1, 99.9)
    printContent = printContent + formatter.formatPrintOrderItem("Braised Squid", 5, 19.99)
    printContent = printContent + "-" * 32 + "<BR>"
    printContent = printContent + "<R>" + "total:" + "327.83" + "RMB" + "<BR></R>"

    printContent = printContent + "<BR>"
    printContent = printContent + "<L>" \
                   + "address:" + "Broadway, New York City" + "<BR>" \
                   + "phone:" + "1363*****88" + "<BR>" \
                   + "orderTime" + "2020-9-9 15:07:57" + "<BR>" \
                   + "remarks:" + "Less spicy" + "<BR>"

    printContent = printContent + "<C>" \
                   + "<QR>https:#www.xpyun.net</QR>" \
                   + "</C>"

    request = model.PrintRequest(USER_NAME, USER_KEY)
    request.user = USER_NAME
    request.userKey = USER_KEY

    # *Required*: The serial number of the printer
    request.sn = OK_PRINTER_SN

    request.generateSign()

    # *Required*: The content to be printed can’t exceed 12288 bytes.
    request.content = printContent

    # The number of printed copies is 1 by default.
    request.copies = 1

    result = service.xpYunPrint(request)
    print(result.httpStatusCode)
    print(result.content)
    print(result.content.code)
    print(result.content.msg)

    # resp.data: Return to order No. correctly
    print(result.content.data)
Ejemplo n.º 7
0
def printFontAlign():
    # 〈BR〉: line break (if there is a closing tag (e.g. 〈/C〉), it should be placed in front of the closing tag, two consecutive line breaks indicate adding a null string.
    # 〈L〉〈/L〉: left aligned
    # 〈C〉〈/C〉: center aligned
    # 〈R〉〈/R〉: right aligned
    # 〈N〉〈/C〉: normal font size
    # 〈HB〉〈/HB〉: double font in height
    # 〈WB〉〈/WB〉: double font in width
    # 〈B〉〈/B〉: double font in size
    # 〈CB〉〈/CB〉: double font in size centred
    # 〈HB2〉〈/HB2〉: three times the font in height
    # 〈WB2〉〈/WB2〉: three times the font in width
    # 〈B2〉〈/B2〉: three times the font in size
    # 〈BOLD〉〈/BOLD〉: bold font
    # 〈LOGO〉〈/LOGO〉: logo (the tag content is a character string in Base64 format, temporarily not opened)
    # 〈OR〉〈/QR〉: QR code (the tag content is a value of QR code, which cannot exceed 256 characters)
    # 〈BARCODE〉〈/BARCODE〉: barcode (the content is a value of barcode)
    # 〈CUT〉: cutter command (active paper cutting, only valid for cutter printer. Note: the print order of cutter printer has a cutter instruction by default in the end.)

    printContent = '''no element:default font<BR>
<BR>
L element: <L>left<BR></L>
<BR>
R element: <R>right<BR></R>
<BR>
C element: <C>center<BR></C>
<BR>
N element:<N>normal font size<BR></N>
<BR>
HB element: <HB>double font height<BR></HB>
<BR>
WB element: <WB>double font width<BR></WB>
<BR>
B element: <B>double font size<BR></B>
<BR>
HB2 element: <HB2>triple font height<BR></HB2>
<BR>
WB2 element: <WB2>triple font width<BR></WB2>
<BR>
B2 element: <B2>triple font size<BR></B2>
<BR>
BOLD element: <BOLD>bold font<BR></BOLD>'''

    printContent = printContent + '<BR>'
    # nested using font and align element
    printContent = printContent + '<C>nested use:<BOLD>center bold</BOLD><BR></C>'

    # print barcode and QR
    printContent = printContent + '<BR>'
    printContent = printContent + '<C><BARCODE>9884822189</BARCODE></C>'
    printContent = printContent + '<C><QR>https:#www.xpyun.net</QR></C>'

    request = model.PrintRequest(USER_NAME, USER_KEY)

    # *Required*: The serial number of the printer
    request.sn = OK_PRINTER_SN
    request.generateSign()

    # *Required*: The content to be printed can’t exceed 12288 bytes.
    request.content = printContent

    # The number of printed copies is 1 by default.
    request.copies = 1

    # Print mode:
    # If the value is 0 or not specified, it will check whether the printer is online. If not online, it will not generate a print order and directly return the status code of an offline device.
    # If online, it will generate a print order and return the print order number.If the value is 1, it will not check whether the printer is online, directly generate a print order and return the print order number.
    # If the printer is not online, the order will be cached in the print queue and will be printed automatically when the printer is normally online.
    request.mode = 0

    result = service.xpYunPrint(request)
    print(result.httpStatusCode)
    print(result.content)
    print(result.content.code)
    print(result.content.msg)

    # resp.data: Return to order No. correctly
    print(result.content.data)
Ejemplo n.º 8
0
def printFontAlignVoiceSupport():
    # 〈BR〉: line break (if there is a closing tag (e.g. 〈/C〉), it should be placed in front of the closing tag, two consecutive line breaks indicate adding a null string.
    # 〈L〉〈/L〉: left aligned
    # 〈C〉〈/C〉: center aligned
    # 〈R〉〈/R〉: right aligned
    # 〈N〉〈/C〉: normal font size
    # 〈HB〉〈/HB〉: double font in height
    # 〈WB〉〈/WB〉: double font in width
    # 〈B〉〈/B〉: double font in size
    # 〈CB〉〈/CB〉: double font in size centred
    # 〈HB2〉〈/HB2〉: three times the font in height
    # 〈WB2〉〈/WB2〉: three times the font in width
    # 〈B2〉〈/B2〉: three times the font in size
    # 〈BOLD〉〈/BOLD〉: bold font
    # 〈LOGO〉〈/LOGO〉: logo (the tag content is a character string in Base64 format, temporarily not opened)
    # 〈OR〉〈/QR〉: QR code (the tag content is a value of QR code, which cannot exceed 256 characters)
    # 〈BARCODE〉〈/BARCODE〉: barcode (the content is a value of barcode)
    # 〈CUT〉: cutter command (active paper cutting, only valid for cutter printer. Note: the print order of cutter printer has a cutter instruction by default in the end.)

    printContent = '''no element:default font<BR>
<BR>
L element: <L>left<BR></L>
<BR>
R element: <R>right<BR></R>
<BR>
C element: <C>center<BR></C>
<BR>
N element:<N>normal font size<BR></N>
<BR>
HB element: <HB>double font height<BR></HB>
<BR>
WB element: <WB>double font width<BR></WB>
<BR>
B element: <B>double font size<BR></B>
<BR>
HB2 element: <HB2>triple font height<BR></HB2>
<BR>
WB2 element: <WB2>triple font width<BR></WB2>
<BR>
B2 element: <B2>triple font size<BR></B2>
<BR>
BOLD element: <BOLD>bold font<BR></BOLD>'''

    printContent = printContent + '<BR>'
    # nested using font and align element
    printContent = printContent + '<C>nested use:<BOLD>center bold</BOLD><BR></C>'

    # print barcode and QR
    printContent = printContent + '<BR>'
    printContent = printContent + '<C><BARCODE>9884822189</BARCODE></C>'
    printContent = printContent + '<C><QR>https:#www.xpyun.net</QR></C>'

    request = model.PrintRequest(USER_NAME, USER_KEY)

    # *Required*: The serial number of the printer
    request.sn = OK_PRINTER_SN
    request.generateSign()

    # *Required*: The content to be printed can’t exceed 12288 bytes.
    request.content = printContent

    # The number of printed copies is 1 by default.
    request.copies = 1

    # Print mode:
    # If the value is 0 or not specified, it will check whether the printer is online. If not online, it will not generate a print order and directly return the status code of an offline device.
    # If online, it will generate a print order and return the print order number.If the value is 1, it will not check whether the printer is online, directly generate a print order and return the print order number.
    # If the printer is not online, the order will be cached in the print queue and will be printed automatically when the printer is normally online.
    request.mode = 0

    # payment method:
    # Value range 41~55:
    # Alipay 41, WeChat 42, Cloud Payment 43, UnionPay Swipe 44, UnionPay Payment 45, Member Card Consumption 46, Member Card Recharge 47, Yipay 48, Successful Collection 49, Jialian Payment 50, One Wallet 51, JD Pay 52, Quick money payment 53, Granville payment 54, Xiangqian payment 55
    # It is only used for Xinye cloud printers that support the amount broadcast.
    request.payType = 41

    # Pay or not:
    # Value range 59~61:
    # Refund 59 to account 60 consumption 61.
    # It is only used for Xinye cloud printers that support the amount broadcast.
    request.payMode = 60

    # Payment amount:
    # Up to 2 decimal places are allowed.
    # It is only used for Xinye cloud printers that support the amount broadcast.
    request.money = 20.15

    result = service.xpYunPrint(request)
    print(result.httpStatusCode)
    print(result.content)
    print(result.content.code)
    print(result.content.msg)

    # resp.data: Return to order No. correctly
    print(result.content.data)