brother_ql.raster - Implementation of Brother’s Raster Language

This module contains the implementation of the raster language of the Brother QL-series label printers according to their documentation and to reverse engineering efforts.

The central piece of code in this module is the class BrotherQLRaster.

class BrotherQLRaster(model='QL-500')[source]

This class facilitates the creation of a complete set of raster instructions by adding them one after the other using the methods of the class. Each method call is adding instructions to the member variable data.

Instatiate the class by providing the printer model as argument.

Parameters:

model (str) – Choose from the list of available models.

Variables:
  • data (bytes) – The resulting bytecode with all instructions.
  • exception_on_warning (bool) – If set to True, an exception is raised if trying to add instruction which are not supported on the selected model. If set to False, the instruction is simply ignored and a warning sent to logging/stderr.
two_color_support
add_initialize()[source]
add_status_information()[source]

Status Information Request

add_switch_mode()[source]

Switch dynamic command mode Switch to the raster mode on the printers that support the mode change (others are in raster mode already).

add_invalidate()[source]

clear command buffer

mtype
mwidth
mlength
pquality
add_media_and_quality(rnumber)[source]
add_autocut(autocut=False)[source]
add_cut_every(n=1)[source]
add_expanded_mode()[source]
add_margins(dots=35)[source]
add_compression(compression=True)[source]

Add an instruction enabling or disabling compression for the transmitted raster image lines. Not all models support compression. If the specific model doesn’t support it but this method is called trying to enable it, either a warning is set or an exception is raised depending on the value of exception_on_warning

Parameters:compression (bool) – Whether compression should be on or off
get_pixel_width()[source]
add_raster_data(image, second_image=None)[source]

Add the image data to the instructions. The provided image has to be binary (every pixel is either black or white).

Parameters:
  • image (PIL.Image.Image) – The image to be converted and added to the raster instructions
  • second_image (PIL.Image.Image) – A second image with a separate color layer (red layer for the QL-800 series)
add_print(last_page=True)[source]