Ejemplo n.º 1
1
#!/usr/bin/env python2
# coding: utf-8

import socket
from brotherprint import BrotherPrint

def getLined(txt):
	pass

f_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
f_socket.connect(('172.22.27.26', 9100))
printjob = BrotherPrint(f_socket)

printjob.command_mode()
printjob.initialize()
printjob.select_font('lettergothic')
printjob.char_size('42')
printjob.char_size('75')
printjob.bold('on')
#printjob.select_charset("Germany")
#printjob.select_char_code_table("western european")
#txt = 28*"x"
txt = "öäü".decode('utf8').encode('iso-8859-1')

printjob.send(txt)
printjob.print_page('full')
Ejemplo n.º 2
0
    def printText(
            self,
            txt,
            charSize='42',
            font='lettergothic',
            align='left',
            bold='off',
            charStyle='normal',
            cut='full'
    ):
        print "start printing:", txt
        import socket
        from brotherprint import BrotherPrint

        f_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        f_socket.settimeout(conf.PRINTER_TIMEOUT)
        f_socket.connect((conf.PRINTER_HOST, conf.PRINTER_PORT))
        printjob = BrotherPrint(f_socket)

        printjob.command_mode()
        printjob.initialize()
        printjob.select_font(font)
        printjob.char_size(charSize)  # 28 chars
        printjob.alignment(align)
        printjob.bold(bold)
        printjob.char_style(charStyle)
        printjob.cut_setting(cut)

        printjob.send(txt.decode('utf8').encode('iso-8859-1'))
        printjob.print_page('full')
Ejemplo n.º 3
0
    def printText(self,
                  txt,
                  charSize='42',
                  font='lettergothic',
                  align='left',
                  bold='off',
                  charStyle='normal',
                  cut='full'):
        print "start printing:", txt
        import socket
        from brotherprint import BrotherPrint

        f_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        f_socket.settimeout(conf.PRINTER_TIMEOUT)
        f_socket.connect((conf.PRINTER_HOST, conf.PRINTER_PORT))
        printjob = BrotherPrint(f_socket)

        printjob.command_mode()
        printjob.initialize()
        printjob.select_font(font)
        printjob.char_size(charSize)  # 28 chars
        printjob.alignment(align)
        printjob.bold(bold)
        printjob.char_style(charStyle)
        printjob.cut_setting(cut)

        printjob.send(txt.decode('utf8').encode('iso-8859-1'))
        printjob.print_page('full')
Ejemplo n.º 4
0
class CodeNowPrinter(object):

    def __init__(self, ip, port=9100):
        self.f_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.f_socket.connect((ip, port))
        self.printjob = BrotherPrint(self.f_socket)

        self.printjob.command_mode()
        self.printjob.initialize()

        self.printjob.rotated_printing('rotate')
        self.printjob.page_length(1100)

    def print_nametag(self, name):
        self.printjob.select_font('brusselsoutline')

        self._print_codenow_header()
        self._skip_lines(5)
        self._print_name(name)

        self.printjob.print_page('full')

    def _skip_lines(self, num_lines):
        for i in xrange(0, num_lines):
            self.printjob.carriage_return()

    def _print_codenow_header(self):
        '''
        Prints the codenow header
        '''
        self.printjob.alignment('center')
        self.printjob.char_size('117')

        self.printjob.bold('on')
        self.printjob.send("Code")
        self.printjob.bold('off')

        self.printjob.italic('on')
        self.printjob.send("Now")
        self.printjob.italic('off')

        self.printjob.carriage_return()
        self.printjob.alignment('left')

    def _print_name(self, name):
        self.printjob.alignment('center')
        self.printjob.char_size('150')

        self.printjob.send(name)
        self.printjob.carriage_return()

        self.printjob.alignment('left')
Ejemplo n.º 5
0
    def printBarcode(self, txt, barcode, characters='on', height=100, width='medium', parentheses='on', ratio='3:1', equalize='off'):
        '''
        characters='on', characters: Whether you want characters below the bar code. 'off' or 'on'
        height=100, height: Height, in dots.
        width='medium' width: width of barcode. Choose 'xsmall' 'small' 'medium' 'large'
        parentheses='on', parentheses: Parentheses deletion on or off. 'on' or 'off' Only matters with GS1-128
        ratio='3:1', ratio: ratio between thick and thin bars. Choose '3:1', '2.5:1', and '2:1'
        equalize='off' equalize: equalize bar lengths, choose 'off' or 'on'
        '''
        f_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        f_socket.settimeout(conf.PRINTER_TIMEOUT)
        f_socket.connect((conf.PRINTER_HOST, conf.PRINTER_PORT))
        printjob = BrotherPrint(f_socket)

        printjob.command_mode()
        printjob.initialize()

        printjob.barcode(txt, barcode, characters, height, width, parentheses, ratio, equalize)
        printjob.print_page('full')
Ejemplo n.º 6
0
def testRaster(printjob):
    printjob.invalidate()
    printjob.initialize()
    printjob.raster_mode()
    #printjob.print_line()
    #printjob.print_line()
    #printjob.print_line()

def testBarcode(printjob):
    barcodes = ['code39', 'itf', 'ean8/upca', 'upce', 'codabar', 'code128', 'gs1-128', 'rss']

    # nope: 'code39', itf, ean8/upca, upce, codabar,  gs1-128
    #'itf',
    #printjob.qr_code("test123", cell_size=10)
    #printjob.barcode(str(123), 'rss', rss_symbol='rsslimited')

f_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
f_socket.connect(('172.22.27.26', 9100))
printjob = BrotherPrint(f_socket)

printjob.command_mode()
printjob.initialize()
#testRaster(printjob)
#testBarcode(printjob)

testLabel(printjob)


printjob.print_page('full')