Manual - MaxiCode

Introduction

MaxiCode comes from the 2D barcode family. You can encode a specific amount of information within a single barcode.
All the ASCII characters from 0 to 255 are supported. MaxiCode encodes data differently based on the type of characters provided. Some characters are encoded with a higher compression level. See the compression level on the technical page.

This class inherits the BCGBarcode2D class.

Example

Methods

BCGmaxicode's Methods

BCGBarcode2D's Methods

BCGBarcode's Methods

Code Example


<?php
use BarcodeBakery\Common\BCGColor;
use BarcodeBakery\Common\BCGDrawing;
use BarcodeBakery\Barcode\BCGmaxicode;

$colorBlack = new BCGColor(0, 0, 0);
$colorWhite = new BCGColor(255, 255, 255);

// Barcode Part
$code = new BCGmaxicode();
$code->setScale(3);
$code->setForegroundColor($colorBlack);
$code->setBackgroundColor($colorWhite);
$code->setMode(4);
$code->parse('Maxicode');

// Drawing Part
$drawing = new BCGDrawing($code, $colorWhite);

header('Content-Type: image/png');

$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
?>

Method explanations

  • getQuietZone() — Gets if the quiet zone will be drawn
    Returns
    bool - true if activated, false otherwise
  • setQuietZone($quietZone) — Specifies to draw a quiet zone around the barcode
    Description
    To be read correctly, the MaxiCode must have a quiet zone around the image. You can, however, turn this off.
    The default value is true.
  • getMode() — Gets the barcode mode
    Description
    Gets the barcode mode.
    Returns
    int
  • setMode($mode) — Specifies the mode
    Description
    Specifies the mode to generate the barcode. You can use a mode from 2 to 6. See the technical information page for more information.
    The default value is 4.
  • setPrimaryMessage($serviceClass, $countryCode, $postalCode) — Sets the primary message
    Description
    Sets the primary message for modes 2 or 3. If you use this method, you can use the parse() method to populate the secondary message. If you don't use this method but use modes 2 or 3, the barcode will try to extract the data from the message passed to the parse() method.
    The service class must be a number between 0 and 999. The country code must be an ISO 3166 country number between 0 and 999. The postal code can be numeric only (mode 2), or alphanumberic (mode 3).
    Set the $serviceClass to -1 to reset the primary message.
  • setAcceptECI($accept) — Specifies to accepts the ECI codes
    Description
    By setting true in this argument, the backslash characters (ASCII 92 \) will be processed as special characters. These are the special characters you can write.
    - \\ : Writes a simple backslash
    - \xxxxxx : Writes the ECI xxxxxx character with x representing an integer from 0 to 9
    The default value is false.
  • setStructuredAppend($snum, $st) — Specifies that data will be expanded between multiple barcodes
    Description
    MaxiCode data can be separated throughout many different barcodes.
    The first argument is the barcode number (beginning with 1), the second argument is the total number of barcodes you have.
    It is possible to encode the data on a maximum of 8 different barcodes.
    Returns
    bool - true on success, false on failure
  • setScaleX($scaleX) — Sets the scaling X for the barcode
    Description
    The width in pixel of one module.
    The default value is 1.
    Note that this method is protected.
  • setScaleY($scaleY) — Sets the scaling Y for the barcode
    Description
    The height in pixel of one module.
    The default value is 1.
    Note that this method is protected.
  • parse($text) — Analyzes a $text message to draw afterwards
    Description
    The data you pass to the $text argument must be supported by the type of barcode you use.
    Check each barcode's introduction section to obtain more information on how to use this method within each symbology.
  • draw($image) — Draws the barcode on the $image
    Description
    The value of the $image argument must be an image resource. The size of the image can be defined by the value received from getDimension().
  • getDimension($width, $height) — Returns an array containing the required size for the image
    Description
    Returns an array in which the first index is the image width and the second index is the image height.
    The arguments are used to specify the starting point of the drawing. Should be 0 for both.
    The BCGDrawing class uses this method to create the image resource.
    Returns
    array(int, int) - [0] is the width, [1] is the height
  • getScale() — Gets the scale of the barcode
    Description
    Gets the scale of the barcode. The value is the number of the "smallest" unit in pixel.
    Returns
    int - value in pixels
  • setScale($scale) — Sets the scale of the barcode
    Description
    The barcode will be $x times bigger. Then a pixel will be $x by $x for its size.
  • getForegroundColor() — Gets the color of the bars
    Description
    Gets the color of the bars of the barcode.
    Returns
  • setForegroundColor($color) — Sets the color of the bars
    Description
    Sets the color of the bars of the barcode. By default, the color is black. This argument can be a BCGColor class or any other argument that BCGColor can accept in its constructor.
  • getBackgroundColor() — Gets the color of the spaces
    Description
    Gets the color of the spaces of the barcode.
    Returns
  • setBackgroundColor($color) — Sets the color of the spaces
    Description
    Sets the color of the spaces of the barcode. By default, the color is white. This argument can be a BCGColor class or any other argument that BCGColor can accept in its constructor.
  • setColor($foregroundColor, $backgroundColor) — Sets the color of the bars and spaces
    Description
    An easy and fast method to set the color of the bars and spaces. Check the setForegroundColor() and setBackgroundColor().
  • getOffsetX() — Gets the X offset
    Description
    Gets the X offset of the barcode in pixels. The value isn't multiplied by the scale.
    Returns
    int - value in pixels
  • setOffsetX($value) — Sets the X offset
    Description
    Specifies the X offset of the barcode in pixels multiplied by the scale. The required size returned by getDimension() will be modified accordingly.
  • getOffsetY() — Gets the Y offset
    Description
    Gets the Y offset of the barcode in pixels. The value isn't multiplied by the scale.
    Returns
    int - value in pixels
  • setOffsetY($value) — Sets the Y offset
    Description
    Specifies the Y offset of the barcode in pixels multiplied by the scale. The required size returned by getDimension() will be modified accordingly.
  • addLabel($label) — Adds a label to the graphic
    Description
    Adds a BCGLabel object to the drawing.
  • removeLabel($label) — Removes a label from the graphic
    Description
    Removes a specific BCGLabel object from the drawing.
  • clearLabels() — Removes the labels from the graphic
    Description
    Clears the BCGLabel objects from the drawing.