commit
9fdb382c99
21
README.md
21
README.md
|
@ -10,7 +10,7 @@ In order to start getting access to your printer, you must ensure
|
|||
you have previously installed the following python modules:
|
||||
|
||||
* pyusb (python-usb)
|
||||
* PIL (Python Image Library)
|
||||
* PIL (Python Image Library) or Pillow (recommended)
|
||||
|
||||
2. Description
|
||||
------------------------------------------------------------------
|
||||
|
@ -69,16 +69,15 @@ The following example shows how to initialize the Epson TM-TI88IV
|
|||
*** NOTE: Always finish the sequence with Epson.cut() otherwise
|
||||
you will endup with weird chars being printed.
|
||||
|
||||
from escpos import *
|
||||
|
||||
""" Seiko Epson Corp. Receipt Printer M129 Definitions (EPSON TM-T88IV) """
|
||||
Epson = escpos.Escpos(0x04b8,0x0202,0)
|
||||
Epson.text("Hello World")
|
||||
Epson.image("logo.gif")
|
||||
Epson.fullimage("a.really.large.image.png")
|
||||
Epson.barcode
|
||||
Epson.barcode('1324354657687','EAN13',64,2,'','')
|
||||
Epson.cut()
|
||||
from escpos import printer
|
||||
|
||||
p = printer.Usb(0x04b8, 0x0202)
|
||||
p.text("Hello World")
|
||||
p.image("doge.jpg")
|
||||
p.fullimage("a.really.large.image.png")
|
||||
p.barcode('1324354657687','EAN13',64,2,'','')
|
||||
p.qr('this is a piece of code')
|
||||
p.cut()
|
||||
|
||||
5. Links
|
||||
------------------------------------------------------------------
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
@license: GPL
|
||||
'''
|
||||
|
||||
import Image
|
||||
import qrcode
|
||||
import time
|
||||
import os
|
||||
import time
|
||||
import qrcode
|
||||
import operator
|
||||
from PIL import Image
|
||||
|
||||
from constants import *
|
||||
from exceptions import *
|
||||
|
@ -37,7 +37,7 @@ class Escpos:
|
|||
i = 0
|
||||
cont = 0
|
||||
buffer = ""
|
||||
|
||||
|
||||
self._raw(S_RASTER_N)
|
||||
buffer = "%02X%02X%02X%02X" % (((size[0]/size[1])/8), 0, size[1], 0)
|
||||
self._raw(buffer.decode('hex'))
|
||||
|
@ -135,21 +135,21 @@ class Escpos:
|
|||
break
|
||||
elif im_color > (255 * 3 / pattern_len * pattern_len) and im_color <= (255 * 3):
|
||||
pix_line += im_pattern[-1]
|
||||
break
|
||||
break
|
||||
pix_line += im_right
|
||||
img_size[0] += im_border[1]
|
||||
|
||||
self._print_image(pix_line, img_size)
|
||||
|
||||
def qr(self,text):
|
||||
def qr(self, text):
|
||||
""" Print QR Code for the provided string """
|
||||
qr_code = qrcode.QRCode(version=4, box_size=4, border=1)
|
||||
qr_code.add_data(text)
|
||||
qr_code.make(fit=True)
|
||||
qr_img = qr_code.make_image()
|
||||
im = qr_img._img.convert("RGB")
|
||||
# Convert the RGB image in printable image
|
||||
self._convert_image(im)
|
||||
im = qr_img._img.convert("RGB")
|
||||
self.image(im)
|
||||
|
||||
def barcode(self, code, bc, width, height, pos, font):
|
||||
""" Print Barcode """
|
||||
|
@ -177,9 +177,9 @@ class Escpos:
|
|||
self._raw(BARCODE_TXT_BTH)
|
||||
elif pos.upper() == "ABOVE":
|
||||
self._raw(BARCODE_TXT_ABV)
|
||||
else: # DEFAULT POSITION: BELOW
|
||||
else: # DEFAULT POSITION: BELOW
|
||||
self._raw(BARCODE_TXT_BLW)
|
||||
# Type
|
||||
# Type
|
||||
if bc.upper() == "UPC-A":
|
||||
self._raw(BARCODE_UPC_A)
|
||||
elif bc.upper() == "UPC-E":
|
||||
|
@ -202,11 +202,11 @@ class Escpos:
|
|||
else:
|
||||
raise exception.BarcodeCodeError()
|
||||
|
||||
|
||||
|
||||
def text(self, txt):
|
||||
""" Print alpha-numeric text """
|
||||
if txt:
|
||||
self._raw(txt)
|
||||
self._raw(txt.encode('cp936'))
|
||||
else:
|
||||
raise TextError()
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class Usb(Escpos):
|
|||
self.interface = interface
|
||||
self.in_ep = in_ep
|
||||
self.out_ep = out_ep
|
||||
self.open()
|
||||
self.open()
|
||||
|
||||
|
||||
def open(self):
|
||||
|
|
2
setup.py
2
setup.py
|
@ -9,7 +9,7 @@ setup(
|
|||
download_url='http://python-escpos.googlecode.com/files/python-escpos-1.0.zip',
|
||||
description='Python library to manipulate ESC/POS Printers',
|
||||
license='GNU GPL v3',
|
||||
long_description=open('README').read(),
|
||||
long_description=open('README.md').read(),
|
||||
author='Manuel F Martinez',
|
||||
author_email='manpaz@bashlinux.com',
|
||||
platforms=['linux'],
|
||||
|
|
Loading…
Reference in New Issue