Created
March 2, 2020 13:35
-
-
Save mcxiaoke/6805b3ab9929fa97f87d4e383033e5d1 to your computer and use it in GitHub Desktop.
escpos printer demo for btp-n58ii
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from escpos import printer | |
from PIL import Image | |
Epson = printer.Usb(0x154f, 0x154f, 0, out_ep=0x02) | |
Epson.codepage='gbk' | |
Epson.set(align='center') | |
# Print text | |
Epson.text(u"这是一只大熊猫") | |
#Epson.codepage=None | |
Epson.text("\n") | |
# Print image | |
im=Image.open('panda.jpg') | |
im.thumbnail((400,200)) | |
im.save('./panda_thumbnail.jpg','JPEG') | |
Epson.image("panda_thumbnail.jpg") | |
# Print QR Code | |
Epson.text("\n") | |
Epson.qr("https://mcxiaoke.com", size=8) | |
# Print barcode | |
Epson.text("\n") | |
Epson.barcode('1234567891011','EAN13',64,4) | |
# Cut paper | |
Epson.cut() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment