Zebrafy
Submodules
zebrafy.zebrafy_image module
- class zebrafy.zebrafy_image.ZebrafyImage(image, compression_type=None, format=None, invert=None, dither=None, threshold=None, width=None, height=None, pos_x=None, pos_y=None, rotation=None, string_line_break=None, complete_zpl=None)[source]
Bases:
objectConvert a PIL Image or image bytes into Zebra Programming Language (ZPL).
- Parameters:
image (
Union[bytes,Image]) – Image as a PIL Image or bytes object.(deprecated) (compression_type) –
ZPL compression type parameter that accepts the following values, defaults to
"A":"A": ASCII hexadecimal - most compatible (default)"B": Base64 binary"C": LZ77 / Zlib compressed base64 binary - best compression
format (
str) –ZPL format parameter that accepts the following values, defaults to
"ASCII":"ASCII": ASCII hexadecimal - most compatible (default)"B64": Base64 binary"Z64": LZ77 / Zlib compressed base64 binary - best compression
invert (
bool) – Invert the black and white in resulting image, defaults toFalsedither (
bool) – Dither the pixels instead of hard limit on black and white, defaults toTruethreshold (
int) – Black pixel threshold for undithered image (0-255), defaults to128width (
int) – Width of the image in the resulting ZPL. If0, use default image width, defaults to0height (
int) – Height of the image in the resulting ZPL. If0, use default image height, defaults to0pos_x (
int) – X position of the image on the resulting ZPL, defaults to0pos_y (
int) – Y position of the image on the resulting ZPL, defaults to0rotation (
int) – Additional rotation in degrees0,90,180, or270, defaults to0string_line_break (
int) – Number of characters in graphic field content after which a new line is added, defaults to None.complete_zpl (
bool) – Return a complete ZPL with header and footer included. Otherwise return only the graphic field, defaults toTrue
Deprecated since version 1.1.0: The compression_type parameter is deprecated in favor of format and will be removed in version 2.0.0.
- property complete_zpl
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property dither
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property format
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property height
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property image
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property invert
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property pos_x
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property pos_y
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property rotation
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property string_line_break
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property threshold
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- to_zpl()[source]
Convert PIL Image or image bytes into Zebra Programming Language (ZPL).
- Return type:
str- Returns:
A complete ZPL file string which can be sent to a ZPL compatible printer or a ZPL graphic field if complete_zpl is not set.
- property width
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
zebrafy.zebrafy_pdf module
- class zebrafy.zebrafy_pdf.ZebrafyPDF(pdf_bytes, compression_type=None, format=None, invert=None, dither=None, threshold=None, dpi=None, width=None, height=None, pos_x=None, pos_y=None, rotation=None, string_line_break=None, split_pages=None, complete_zpl=None)[source]
Bases:
objectProvides a method for converting PDFs to Zebra Programming Language (ZPL).
- Parameters:
pdf_bytes (
bytes) – PDF as a bytes object.(deprecated) (compression_type) –
ZPL compression type parameter that accepts the following values, defaults to
"A":"A": ASCII hexadecimal - most compatible (default)"B": Base64 binary"C": LZ77 / Zlib compressed base64 binary - best compression
format (
str) –ZPL format parameter that accepts the following values, defaults to
"ASCII":"ASCII": ASCII hexadecimal - most compatible (default)"B64": Base64 binary"Z64": LZ77 / Zlib compressed base64 binary - best compression
invert (
bool) – Invert the black and white in resulting image, defaults toFalsedither (
bool) – Dither the pixels instead of hard limit on black and white, defaults toTruethreshold (
int) – Black pixel threshold for undithered PDF (0-255), defaults to128dpi (
int) – Pixels per PDF canvas unit. This defines the resolution scaling of the image (<72: compress, >72: stretch), defaults to72width (
int) – Width of the PDF in the resulting ZPL. If0, use default PDF width, defaults to0height (
int) – Height of the PDF in the resulting ZPL. If0, use default PDF height, defaults to0pos_x (
int) – X position of the PDF on the resulting ZPL, defaults to0pos_y (
int) – Y position of the PDF on the resulting ZPL, defaults to0rotation (
int) – Additional rotation in degrees0,90,180, or270, defaults to0string_line_break (
int) – Number of characters in graphic field content after which a new line is added, defaults to None.split_pages (
bool) – Split each PDF page as a new ZPL label (only applies if complete_zpl is set), defaults toFalsecomplete_zpl (
bool) – Return a complete ZPL with header and footer included. Otherwise return only the graphic field, defaults toTrue
Deprecated since version 1.1.0: The compression_type parameter is deprecated in favor of format and will be removed in version 2.0.0.
- property complete_zpl
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property dither
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property dpi
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property format
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property height
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property invert
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property pdf_bytes
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property pos_x
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property pos_y
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property rotation
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property split_pages
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property string_line_break
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property threshold
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- to_zpl()[source]
Convert PDF bytes to Zebra Programming Language (ZPL).
- Return type:
str- Returns:
A complete ZPL file string which can be sent to a ZPL compatible printer or a ZPL graphic field if complete_zpl is not set.
- property width
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
zebrafy.zebrafy_zpl module
- class zebrafy.zebrafy_zpl.ZebrafyZPL(zpl_data)[source]
Bases:
objectConvert Zebra Programming Language (ZPL) graphic fields to PDF and images.
- Parameters:
zpl_data (
str) – A valid ZPL string.
- to_images()[source]
Convert Zebra Programming Language (ZPL) graphic fields to PIL Image objects.
- Return type:
list[Image]- Returns:
A list containing PIL Images converted from ZPL graphic fields.
- to_pdf()[source]
Convert Zebra Programming Language (ZPL) graphic fields to PDF.
- Return type:
bytes- Returns:
PDF bytes from ZPL graphic fields.
- property zpl_data
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
zebrafy.crc module
- class zebrafy.crc.CRC(data_bytes, poly=None)[source]
Bases:
objectUtility class to calculate CRC-16-CCITT algorithm across the received data bytes.
CRC-16-CCITT polynomial representation: x^{16} + x^{12} + x^5 + 1
- Parameters:
data_bytes (
bytes) – Bytes object for which to calculate CRCpoly (
int) – Reversed polynomial representation for CRC-16-CCITT calculation, defaults to0x8408
- property data_bytes
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- get_crc_hex_string()[source]
Get CRC-16-CCITT as four digit zero padding hexadecimal string.
- Return type:
str- Returns:
CRC-16-CCITT as four digit zero padding hexadecimal string
- property poly
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
zebrafy.graphic_field module
- class zebrafy.graphic_field.GraphicField(pil_image, compression_type=None, format=None, string_line_break=None)[source]
Bases:
objectConverts a PIL image to Zebra Programming Language (ZPL) graphic field data.
- Parameters:
image (PIL.Image.Image) – An instance of a PIL Image.
(deprecated) (compression_type) –
ZPL compression type parameter that accepts the following values, defaults to
"A":"A": ASCII hexadecimal - most compatible (default)"B": Base64 binary"C": LZ77 / Zlib compressed base64 binary - best compression
format (
str) –ZPL format parameter that accepts the following values, defaults to
"ASCII":"ASCII": ASCII hexadecimal - most compatible (default)"B64": Base64 binary"Z64": LZ77 / Zlib compressed base64 binary - best compression
string_line_break (
int) – Number of characters in graphic field content after which a new line is added, defaults to None.
Deprecated since version 1.1.0: The compression_type parameter is deprecated in favor of format and will be removed in version 2.0.0.
- property format
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- get_graphic_field()[source]
Get a complete graphic field string for ZPL.
- Return type:
str- Returns:
Complete graphic field string for ZPL.
- property pil_image
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).
- property string_line_break
Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter(‘name’), the call f(r) returns r.name. After g = attrgetter(‘name’, ‘date’), the call g(r) returns (r.name, r.date). After h = attrgetter(‘name.first’, ‘name.last’), the call h(r) returns (r.name.first, r.name.last).