Esempio n. 1
0
def genera_boletos(rango):
    font2 = ImageFont.truetype("/home/francisco/Carousel.ttf", 60)
    font = ImageFont.truetype("/home/francisco/gunplay3.ttf", 120)
    generar_imagen_font('Boleto', font2, 'boleto.png')
    p = Usb(0x04b8, 0x0202)
    sa = "niñoññ"
    for x in rango:
        nombre_imagen = 'a_number{}.png'.format(x)
        generar_imagen_font(str(x), font, nombre_imagen)
        p.set(align='center', font='b')
        p.charcode(code="NORDIC")
        p.image("FantasyWorld.png")
        p.text(
            "Venta de articulos de belleza,  cosmeticos,  regalos, y  juguetes."
            + "\n\n")
        p.image("boleto.png")
        p.image(nombre_imagen)
        p.text(
            "Fantasy  les  desea  una  feliz  navidad y prospero anio nuevo\n")
        p.text(
            "La rifa se llevara a cabo el dia 6 de enero del 2018 a  las 12:00 pm\n"
        )
        p.text("Gracias por su preferencia\n")
        p.cut()
        p.image("boleto.png")
        p.image(nombre_imagen)
        p.text("\n________________________________________" + "\n")
        p.text("Nombre\n\n")
        p.set(align='center', font='a')
        p.text("Deposite este boleto en la urna")
        p.cut()
Esempio n. 2
0
class ThermalPrinter():
    def __init__(self):
        self.p = Usb(0x0fe6, 0x811e, 98, 0x82, 0x02)

    def insert_imagen(self, img_surce):
        self.p.image(img_surce)

    def insert_qr(self, content, size):
        self.p.qr(content, size=size)  #size 1 - 16 default 3

    def insert_barcode(self, code, bc, height, width):
        self.p.barcode(code, bc, height=height, width=width)

    def insert_text(self, txt):
        self.p.text(txt)

    def insert_raw_txt(self, txt):
        self.p._raw(txt)

    # harware action, may be: INIT, SELECT, RESET
    def hardware_operation(self, hw):
        self.p.hw(hw)

    #string for the following control sequences:
    # LF for Line Feed
    # FF for Form Feed
    # CR for Carriage Return
    # HT for Horizontal Tab
    # VT for Vertical Tab
    #pos = horizontal tab position 1 - 16
    def feed_control(self, ctl, pos):
        self.p.control()

        self.p.charcode()


#   #def insert_textln(self, txt):
# align = CENTER LEFT RIGHT  default left
# font_type = A or B         default A
# textt_type = B(bold), U(underline), U2(underline, version2), BU(for bold and underlined, NORMAL(normal text) defaul tnormal
# width = width multiplier decimal 1 - 8 defaul 1
# heigh =  height multiplier decimal 1 - 8 defaul 1
# density = density 0 - 8
# def set_txt(self, align, font, text_type, density, height, width):

    def set_txt(self, *args, **Kwargs):
        print(Kwargs)
        self.p.set(Kwargs)

    def cut_paper(self):
        self.p.cut()