Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Added 3of9 Barcode feature #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This piece of code allows you to control a datamax-o'neil label printer. You do
programming language for simple tasks, this module takes care of it.

The module was developed and tested on python 3.6 using a datamax o'neil e-class mark III printer. It still has very
limited functionality allowing you to print text labels and QR-codes. In case you need any other features feel free to
limited functionality allowing you to print text labels,QR-codes and Barcodes. In case you need any other features feel free to
contribute.

## Install
Expand All @@ -29,6 +29,7 @@ printer.configure()
printer.start_document()
printer.set_qr_code(285, 120, 'https://www.innetag.ch/', 9)
printer.set_label(300, 60, 'innetag.ch', 9, 10)
printer.set_barcode('0266','0025','1039001234',1)
printer.print()
```

Expand Down
24 changes: 24 additions & 0 deletions datamax_printer/datamax_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,30 @@ def set_qr_code(self, x_pos, y_pos, data, size=8):

command = f'1W1d{size}{size}000{y_pos}{x_pos}{data}\x0D\x0D'
return self.__send_to_printer(command)

def set_barcode(self, x_pos, y_pos, data, additional_info, size='000'):
"""
Generates a 3of9 Barcode with a 3:1 ratio
:param additional_info: 1 to add number to bottom of barcode, 0 to have no number
:param x_pos: Position of the barCode on the X-Axis, must be 4 digits eg 0010 (in 0.1mm)
:param y_pos: Position of the barCode on the Y-Axis, must be 4 digits eg 0010 (in 0.1mm)
:param size: height of barcode(in 0.1mm) enter 000 for default (.010mm)
:param data: Data to be encoded in the barcode.
(Numeric Data, Alphanumeric Data, - . * $ / + % and the space character.)
:return: Number of bytes sent to the printer
"""
if self.command_mode:
raise RuntimeError('Cannot print Barcode in command mode')

if additional_info== 0:
additional_info = "a"
elif additional_info == 1:
additional_info = "A"
else:
raise RuntimeError('parameter "additional_info" must either be 0 or 1')
command = f'1{additional_info}42{size}{y_pos}{x_pos}{data}\x0D\x0D'
return self.__send_to_printer(command)


def print(self):
self.__send_to_printer('E')
Expand Down