Skip to main content

Barcode

This library provides functions with which EAN-codes (numeric) can be transformed into glyphs that can be displayed as Barcode using a specific Barcode-Font. Currently supported Barcodes: EAN 8, EAN 13

In this case, the EAN is transformed into Glyphs that can be displayed with the Open-Source Font LibreBarcode.
These fonts are included in the fonts-folder of this project renderpdf/comet/fonts/LibreBarcode(...).ttf.
Font-License at: renderpdf/comet/fonts/LibreBarcode_OFL.txt.

get_ean_13(...)​

(text, error_output=False)​

This function encodes a given EAN-8 as characters to be displayed in the Barcode-Font 'LibreBarcodeEAN13Text-Regular.ttf'.

Parameters:text (str)
Valid EAN-13 including checksum as string.
error_output (bool)
Should an Error-string be created, if the validation fails? May not be displayed correctly using the barcode-font. It is recommended to display error-output using a different font (for example using GREP-styles).
Returns:The encoded barcode String, an empty String if encoding fails or an Error-String, if encoding fails and error_ouput is set to True.
Return Type:str

get_ean_8(...)​

(text:str, error_output=False)​

Encodes a given string of an EAN 8 as characters to be displayed in the Barcode-Font 'LibreBarcodeEAN13Text-Regular.ttf'.

Parameters:text (str)
Valid EAN-8 including checksum as string.
error_output (bool)
Should an Error-string be created, if the validation fails? May not be displayed correctly using the barcode-font. It is recommended to display error-output using a different font (for example using GREP-styles).
Returns:The encoded barcode String, an empty String if encoding fails or an Error-String, if encoding fails and error_ouput is set to True.
Return Type:str

get_barcode_128(...)​

(text:str, ean_length:int, error_output=False)​

This function encodes a given String as characters to be displayed in the Barcode-Font 'LibreBarcode128-Regular.ttf' or 'LibreBarcode128Text-Regular.ttf'.

Parameters:text (str)
A string containing characters allowed in Barcode 128.
error_output (bool)
Should an Error-string be created, if the validation fails? May not be displayed correctly using the barcode-font. It is recommended to display error-output using a different font (for example using GREP-styles).
Returns:The encoded barcode String, an empty String if encoding fails or an Error-String, if encoding fails and error_ouput is set to True.
Return Type:str