Table of contents
Namespace: Com\Tecnick\Barcode
interface Model
Source: src/Model.php:38
Barcode Model interface
Methods
getArray()
Get the barcode raw array
public getArray(): array{'type': string, 'format': string, 'params': (int|float|string)[], 'code': string, 'extcode': string, 'ncols': int, 'nrows': int, 'width': int, 'height': int, 'width_ratio': float, 'height_ratio': float, 'padding': array{'T': int, 'R': int, 'B': int, 'L': int}, 'full_width': int, 'full_height': int, 'color_obj': Rgb, 'bg_color_obj': ?Rgb, 'bars': array{int, int, int, int}[]}
Returns: array{’type’: string, ‘format’: string, ‘params’: (int|float|string)[], ‘code’: string, ’extcode’: string, ’ncols’: int, ’nrows’: int, ‘width’: int, ‘height’: int, ‘width_ratio’: float, ‘height_ratio’: float, ‘padding’: array{‘T’: int, ‘R’: int, ‘B’: int, ‘L’: int}, ‘full_width’: int, ‘full_height’: int, ‘color_obj’: Rgb, ‘bg_color_obj’: ?Rgb, ‘bars’: array{int, int, int, int}[]}
Source: src/Model.php:101
getBarsArrayXYWH()
Get the array containing all the formatted bars coordinates (x, y, width, height)
public getBarsArrayXYWH(): array<int,array{float, float, float, float}>
Returns: array<int,array{float, float, float, float}>
Source: src/Model.php:202
getBarsArrayXYXY()
Get the array containing all the formatted bars coordinates (x1, y1, x2, y2)
public getBarsArrayXYXY(): array<int,array{float, float, float, float}>
Returns: array<int,array{float, float, float, float}>
Source: src/Model.php:195
getExtendedCode()
Get the extended code (code + checksum)
public getExtendedCode(): string
Returns: string
Source: src/Model.php:106
getGd()
Get the barcode as GD image object (requires GD library)
public getGd(): GdImage
Returns: GdImage
Throws:
- Exception: if the GD library is not installed
Source: src/Model.php:170
getGrid()
Get a raw barcode string representation using characters
public getGrid(string $space_char = '0', string $bar_char = '1'): string
Parameters:
$space_char(string): Character or string to use for filling empty spaces$bar_char(string): Character or string to use for filling bars
Returns: string
Source: src/Model.php:178
getGridArray()
Get a raw barcode grid array
public getGridArray(string $space_char = '0', string $bar_char = '1'): array<int,array<int,string>>
Parameters:
$space_char(string): Character or string to use for filling empty spaces$bar_char(string): Character or string to use for filling bars
Returns: array<int,array<int,string>>
Source: src/Model.php:188
getHtmlDiv()
Get an HTML representation of the barcode.
public getHtmlDiv(): string
Returns: string: HTML code (DIV block)
Source: src/Model.php:137
getInlineSvgCode()
Get the barcode as inline SVG code.
public getInlineSvgCode(): string
Returns: string: Inline SVG code.
Source: src/Model.php:123
getPng()
Get Barcode as PNG Image (requires GD or Imagick library)
public getPng(string|null $filename = null): void
Parameters:
$filename(string|null): The file name without extension (optional). Only allows alphanumeric characters, underscores and hyphens. Defaults to a md5 hash of the data. The file extension is always ‘.png’.
Source: src/Model.php:147
getPngData()
Get the barcode as PNG image (requires GD or Imagick library)
public getPngData(bool $imagick = true): string
Parameters:
$imagick(bool): If true try to use the Imagick extension
Returns: string: PNG image data
Source: src/Model.php:156
getPngDataImagick()
Get the barcode as PNG image (requires Imagick library)
public getPngDataImagick(): string
Returns: string
Throws:
- Exception: if the Imagick library is not installed
Source: src/Model.php:163
getSvg()
Get the barcode as SVG image object
public getSvg(string|null $filename = null): void
Parameters:
$filename(string|null): The file name without extension (optional). Only allows alphanumeric characters, underscores and hyphens. Defaults to a md5 hash of the data. The file extension is always ‘.svg’.
Source: src/Model.php:116
getSvgCode()
Get the barcode as SVG code, including the XML declaration.
public getSvgCode(): string
Returns: string: SVG code
Source: src/Model.php:130
setBackgroundColor()
Set the background color
public setBackgroundColor(string $color): static
Parameters:
$color(string): Background color in Web notation (color name, or hexadecimal code, or CSS syntax) or PDF spot color name
Returns: static
Throws:
- Exception: in case of color error
Source: src/Model.php:76
setColor()
Set the color of the bars.
An empty or transparent foreground color is rejected with a BarcodeException.
public setColor(string $color): static
Parameters:
$color(string): Foreground color in Web notation (color name, or hexadecimal code, or CSS syntax) or PDF spot color name
Returns: static
Throws:
Source: src/Model.php:66
setSize()
Set the size of the barcode to be exported
public setSize(int $width, int $height, array{int, int, int, int} $padding = [0, 0, 0, 0]): static
Parameters:
$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.$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 number of rows or columns.
Returns: static
Source: src/Model.php:54