Barcode

Barcode factory class

Namespace: Com\Tecnick\Barcode

class Barcode

Source: src/Barcode.php:36

Barcode factory class

Constants

BARCODETYPES

List of supported Barcode Types with description.

public const BARCODETYPES = ['AUSPOST' => 'Australia Post 4-State Customer Barcode', 'C128' => 'CODE 128', 'C128A' => 'CODE 128 A', 'C128B' => 'CODE 128 B', 'C128C' => 'CODE 128 C', 'C16K' => 'CODE 16K (stacked CODE 128)', 'C32' => 'CODE 32 (Italian Pharmacode - IMH - Radix 32)', 'C49' => 'CODE 49 (ANSI/AIM BC6)', 'C39' => 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.', 'C39+' => 'CODE 39 + CHECKSUM', 'C39E' => 'CODE 39 EXT
// … truncated, see source

Source: src/Barcode.php:49

MAX_CODE_LENGTH

Maximum accepted length in bytes of the barcode payload.

Longer payloads are rejected by getBarcodeObj().

public const MAX_CODE_LENGTH = 30000

Source: src/Barcode.php:42

Methods

getBarcodeObj()

Get the barcode object

public getBarcodeObj(
    string|BarcodeType $type,
    string $code,
    int $width = -1,
    int $height = -1,
    string $color = 'black',
    array{int, int, int, int} $padding = [0, 0, 0, 0]
): Model

Parameters:

  • $type (string|BarcodeType): Barcode type (leading token, optionally followed by comma-separated extra parameters), or a BarcodeType enum case
  • $code (string): Barcode content
  • $width (int): Barcode width in user units (excluding padding). A negative value indicates the multiplication factor for each column.
  • $height (int): Barcode height in user units (excluding padding). A negative value indicates the multiplication factor for each row.
  • $color (string): Foreground color in Web notation (color name, or hexadecimal code, or CSS syntax) or PDF spot color name
  • $padding (array{int, int, int, int}): Additional padding to add around the barcode (top, right, bottom, left) in user units. A negative value indicates the multiplication factor for each row or column.

Returns: Model

Throws:

Source: src/Barcode.php:148