Skip to content

Instantly share code, notes, and snippets.

@mcxiaoke
Created March 2, 2020 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcxiaoke/6805b3ab9929fa97f87d4e383033e5d1 to your computer and use it in GitHub Desktop.
Save mcxiaoke/6805b3ab9929fa97f87d4e383033e5d1 to your computer and use it in GitHub Desktop.
escpos printer demo for btp-n58ii
# 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