Manual - BCGgs1128

Introduction

The GS1-128 code is a normalization of the standards from GS1 based on the BCGcode128. This code is an international standard which provides a way to exchange data between producers and distributors. The GS1-128 must start with the function 1 (~F1). It can contain multiple identifiers, however it mustn't be larger than 48 characters, this limit excludes the mandatory character ~F1. In order to facilitate the reading, the identifiers are surrounded by parentheses in the label; those parentheses are not encoded in the barcode.

There are different ways to send the data of your barcode to the method parse(), for instance, the following code:

IdentifierContent
0112345678912343
92123
15880422

(01)12345678912343(92)123(15)880422

can be encoded like this

  • A formatted string:
    parse('(01)12345678912343(92)123~F1(15)880422')
  • A non-formatted string:
    parse('011234567891234392123~F115880422')
  • A simple formatted table:
    parse(array('(01)12345678912343', '(92)123', '(15)880422'))
  • A simple mixed table:
    parse(array('0112345678912343', '(92)123~F115880422'))
  • A double table containing couples (ID, CONTENT)
    parse(array(array('01', '12345678912343'), array('92', '123'), array('15', '880422')))

* Note about ~F1: If you provide the data in a string, you have to provide a separator at the end of your identifier if this one doesn't cover the maximum and is not positioned at the end of the code.

If you didn't indicate the checksum in the data and it is mandatory, it will be automatically calculated.
ex: parse('011234567891234') will give you: (01)1234567891234 3

There are two standards for the GS1-128, the strict and legacy modes. In legacy mode, separators are added between each identifier. In strict mode, separators are added only if the content of your data doesn't cover the maximum allowed. In this mode, it is highly recommended to use the table C if you use only numbers in your barcode. The following example will help you to understand the difference between those two modes:

Legacy Mode:
(01) content with fixed size [Separator] (91) content with variable size [Separator] (8020) content with variable size

Strict Mode:
(01) content with fixed size (91)content with variable size [Separator *] (8020) content with variable size

* The identifier 91 must contain between 1 and 30 characters. If this one contains 30 characters, there is no separator added.

Identifiers list:

IdNameTypeSizeChecksum
00Serial Shipping Container Code (SSCC-18)Numeric2 + 18yes
01Shipping Container Code (SSC)Numeric2 + 14yes
02Number of containersNumeric2 + 14yes
10Batch NumberAlphanumeric2 + 1 to 20no
11Production DateDate2 + 6no
12Due dateDate2 + 6no
13Packaging DateDate2 + 6no
15Sell by Date (Quality Control)Date2 + 6no
17Expiration DateDate2 + 6no
20Product VariantNumeric2 + 2no
21Serial NumberAlphanumeric2 + 1 to 20no
240Additional Product IdentificationAlphanumeric3 + 1 to 30no
241Customer part numberAlphanumeric3 + 1 to 30no
250Second Serial NumberAlphanumeric3 + 1 to 30no
251Reference to source entityAlphanumeric3 + 1 to 30no
253Global Document Type IdentifierNumeric3 + 14 to 30no
254GLN Extension Component3 + 1 to 20no
30Quantity EachNumeric2 + 1 to 8no
310yProduct Net Weight in kgNumeric4 + 6no
311yProduct Length/1st Dimension, in metersNumeric4 + 6no
312yProduct Width/Diameter/2nd Dimension, in metersNumeric4 + 6no
313yProduct Depth/Thickness/3rd Dimension, in metersNumeric4 + 6no
314yProduct Area, in square metersNumeric4 + 6no
315yProduct Volume, in litersNumeric4 + 6no
316yproduct Volume, in cubic metersNumeric4 + 6no
320yProduct Net Weight, in poundsNumeric4 + 6no
321yProduct Length/1st Dimension, in inchesNumeric4 + 6no
322yProduct Length/1st Dimension, in feetNumeric4 + 6no
323yProduct Length/1st Dimension, in yardsNumeric4 + 6no
324yProduct Width/Diameter/2nd Dimension, in inchesNumeric4 + 6no
325yProduct Width/Diameter/2nd Dimension, in feetNumeric4 + 6no
326yProduct Width/Diameter/2nd Dimension, in yardsNumeric4 + 6no
327yProduct Depth/Thickness/3rd Dimension, in inchesNumeric4 + 6no
328yProduct Depth/Thickness/3rd Dimension, in feetNumeric4 + 6no
329yProduct Depth/Thickness/3rd Dimension, in yardsNumeric4 + 6no
330yContainer Gross Weight (Kg)Numeric4 + 6no
331yContainer Length/1st Dimension (Meters)Numeric4 + 6no
332yContainer Width/Diameter/2nd Dimension (Meters)Numeric4 + 6no
333yContainer Depth/Thickness/3rd Dimension (Meters)Numeric4 + 6no
334yContainer Area (Square Meters)Numeric4 + 6no
335yContainer Gross Volume (Liters)Numeric4 + 6no
336yContainer Gross Volume (Cubic Meters)Numeric4 + 6no
337yKilograms per square meterNumeric4 + 6no
340yContainer Gross Weight (Pounds)Numeric4 + 6no
341yContainer Length/1st Dimension, in inchesNumeric4 + 6no
342yContainer Length/1st Dimension, in feetNumeric4 + 6no
343yContainer Length/1st Dimension in, in yardsNumeric4 + 6no
344yContainer Width/Diameter/2nd Dimension, in inchesNumeric4 + 6no
345yContainer Width/Diameter/2nd Dimension, in feetNumeric4 + 6no
346yContainer Width/Diameter/2nd Dimension, in yardsNumeric4 + 6no
347yContainer Depth/Thickness/Height/3rd Dimension, in inchesNumeric4 + 6no
348yContainer Depth/Thickness/Height/3rd Dimension, in feetNumeric4 + 6no
349yContainer Depth/Thickness/Height/3rd Dimension, in yardsNumeric4 + 6no
350yProduct Area (Square Inches)Numeric4 + 6no
351yProduct Area (Square Feet)Numeric4 + 6no
352yProduct Area (Square Yards)Numeric4 + 6no
353yContainer Area (Square Inches)Numeric4 + 6no
354yContainer Area (Square Feet)Numeric4 + 6no
355yContainer Area (Square Yards)Numeric4 + 6no
356yNet Weight (Troy Ounces)Numeric4 + 6no
357yKilograms per square meterNumeric4 + 6no
360yProduct Volume (Quarts)Numeric4 + 6no
361yProduct Volume (Gallons)Numeric4 + 6no
362yContainer Gross Volume (Quarts)Numeric4 + 6no
363yContainer Gross Volume (Gallons)Numeric4 + 6no
364yProduct Volume (Cubic Inches)Numeric4 + 6no
365yProduct Volume (Cubic Feet)Numeric4 + 6no
366yProduct Volume (Cubic Yards)Numeric4 + 6no
367yContainer Gross Volume (Cubic Inches)Numeric4 + 6no
368yContainer Gross Volume (Cubic Feet)Numeric4 + 6no
369yContainer Gross Volume (Cubic Yards)Numeric4 + 6no
37Number of Units ContainedNumeric2 + 1 to 8no
390yAmount payable-single monetary areaNumeric4 + 1 to 15no
391yAmount payable with ISO currency codeNumeric4 + 4 to 18no
392yAmount payable for a Variable Measure Trade Item single monetary unitNumeric4 + 1 to 15no
393yAmount payable for a Variable Measure Trade Item - with ISO currency codeNumeric4 + 4 to 18no
400Customer Purchase Order NumberAlphanumeric3 + 1 to 30no
401Consignment numberAlphanumeric3 + 1 to 30no
402Shipment Identification NumberNumeric3 + 17no
403Routing codeAlphanumeric3 + 1 to 30no
410Ship To/Deliver To Location Code (EAN13 or DUNS code)Numeric3 + 13yes
411Bill To/Invoice Location Code (EAN13 or DUNS code)Numeric3 + 13yes
412Purchase From Location Code (EAN13 or DUNS code)Numeric3 + 13yes
413Ship for - deliver for - forward to EAN.UCC Global Location NumberNumeric3 + 13yes
414Identification of a physical location EAN.UCC Global Location NumberNumeric3 + 13yes
415EAN.UCC Global Location Number of the invoicing partyNumeric3 + 13yes
420Ship To/Deliver To Postal Code (Single Postal Authority)Alphanumeric3 + 1 to 20no
421Ship To/Deliver To Postal Code (Multiple Postal Authority)Alphanumeric3 + 4 to 12no
422Country of origin of a trade itemNumeric3 + 3no
423Country of Initial ProcessingNumeric3 + 3 to 15no
424Country of ProcessingNumeric3 + 3no
425Country of DisassemblyNumeric3 + 3no
426Country Covering full Process ChainNumeric3 + 3no
7001NATO Stock Number (NSN)Numeric4 + 13no
7002UN/ECE Meat Carcasses and Cuts ClassificationAlphanumeric4 + 1 to 30no
7003Expiration Date and TimeNumeric4 + 10 to no
7004Active PotencyNumeric4 + 1 to 4no
703sApproval Number of Processor with ISO Country CodeAlphanumeric4 + 3 to 31no
8001Roll Products - Width/Length/Core DiameterNumeric4 + 14no
8002Electronic Serial Number (ESN) for Cellular PhoneAlphanumeric4 + 1 to 20no
8003UPC/EAN Number and Serial Number of Returnable AssetAlphanumeric4 + 15 to 30no
8004UPC/EAN Serial IdentificationAlphanumeric4 + 1 to 30no
8005Price per Unit of MeasureNumeric4 + 6no
8006Identification of the component of a trade itemNumeric4 + 18no
8007International Bank Account NumberAlphanumeric4 + 1 to 30no
8008Date and Time of ProductionNumeric4 + 8 to 12no
8018EAN.UCC Global Service Relation NumberNumeric4 + 18no
8020Payment Slip Reference NumberAlphanumeric4 + 1 to 25no
8100Coupon Extended Code: Number System and OfferNumeric4 + 6no
81018101 Coupon Extended Code: Number System, Offer, End of OfferNumeric4 + 10no
8102Coupon Extended Code: Number System preceded by 0Numeric4 + 2no
8110Coupon Code Identification for Use in North AmericaAlphanumeric4 + 1 to 30no
90Mutually Agreed Between Trading PartnersAlphanumeric2 + 1 to 30no
91Internal Company CodesAlphanumeric2 + 1 to 30no
92Internal Company CodesAlphanumeric2 + 1 to 30no
93Internal Company CodesAlphanumeric2 + 1 to 30no
94Internal Company CodesAlphanumeric2 + 1 to 30no
95Internal Company CodesAlphanumeric2 + 1 to 30no
96Internal Company CodesAlphanumeric2 + 1 to 30no
97Internal Company CodesAlphanumeric2 + 1 to 30no
98Internal Company CodesAlphanumeric2 + 1 to 30no
99Internal Company CodesAlphanumeric2 + 1 to 30no

* Date is in the "YYMMDD" format.

This class inherits the BCGcode128 class.

Example

BCGgs1128's Methods



BCGcode128's Methods



BCGBarcode1D's Methods



BCGBarcode's Methods

Code Example

<?php
require('class/BCGFontFile.php');
require('class/BCGColor.php');
require('class/BCGDrawing.php');
require('class/BCGgs1128.barcode.php');
 
$font = new BCGFontFile('./class/font/Arial.ttf', 18);
$color_black = new BCGColor(0, 0, 0);
$color_white = new BCGColor(255, 255, 255);
 
// Barcode Part
$code = new BCGgs1128();
$code->setScale(2);
$code->setThickness(30);
$code->setForegroundColor($color_black);
$code->setBackgroundColor($color_white);
$code->setFont($font);
$code->setStrictMode(true);
$code->parse('011234567891234');
 
// Drawing Part
$drawing = new BCGDrawing('', $color_white);
$drawing->setBarcode($code);
$drawing->draw();
 
header('Content-Type: image/png');
 
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
?>

Methods Explanation

  • __construct($start = NULL) — Specifies by which table the barcode should start
    Description
    The argument can be A, B, C or NULL. See the setStart() method for more information.
    The default value is C.
  • getStrictMode() — Gets if the strict mode is activated
    Description
    See setStrictMode() for more details.
    Returns
    bool - true if activated, false otherwise
  • setStrictMode($mode) — Specifies which mode to use to generate the barcode
    Description
    By setting the argument to true, the strict mode is used, if you set false, the code will be generated following the legacy mode. For more information about those two modes, see the introduction.
    The default value is true.
  • __construct($start = NULL) — Specifies by which table the barcode should start
    Description
    The argument can be A, B, C or NULL. See the setStart() method for more information.
    The default value is NULL.
    This means the table is automatically chosen.
  • setStart($start) — Specifies by which table the barcode should start
    Description
    The argument can be A, B, C or NULL. This selects the table the barcode will start.
    Returns
    The default value is NULL.
    This means the table will be automatically chosen when you provide the text.
    The tables contain different characters which can be encoded in the barcode.
    Check the introduction of this document to obtain more information.
  • getTilde($tilde) — Gets if the behavior for tilde ~ is modified
    Description
    Gets if the behavior for tilde ~ is modified.
    See setTilde() for more details.
    Returns
    bool - true if activated, false otherwise
  • setTilde($tilde) — Modifies the use of the tilde character ~
    Description
    • Writes a simple tilde
    • ~Fx : Write a FNCx character, with x varying between 1 and 4
    Returns
    The default value is true.
  • getThickness() — Returns the thickness of the barcode
    Description
    The thickness of the barcode in pixels. The value isn't multiplied by the scale.
    Returns
    int - value in pixels
  • setThickness($thickness) — Specifies the thickness of the barcode
    Description
    The thickness of the barcode in pixels. This is the vertical size.
    This value is multiplied by the scale. Check the setScale() method.
    The default value is 30.
  • getLabel() — Gets the label
    Description
    Returns the real value that will be displayed with the barcode. You have to have called the parse() method first.
    Returns
    string - final label
  • setLabel($label) — Sets the label
    Description
    The text label will be written below or above the barcode depending on the barcode. You can write the special value BCGBarcode1D::AUTO_LABEL if you would like your text to be chosen automatically. It will be the value passed to the parse() method.
  • getFont() — Gets the text font for the label
    Description
    Gets the text font of the label.
    Returns
  • setFont($font) — Sets the text font for the label
    Description
    The value of the argument can be either an instance of the BCGFontFile class, BCGFontPhp, or a number between 1 and 5.
    If you are using numbers 1 through 5, PHP fonts are used. Check the PHP Manual.
  • getChecksum() — Gets the checksum appended to the barcode
    Description
    Returns the value that will be appended to the barcode. This method must be called after the method parse().
    Returns
    int - checksum added or false if no checkum is included
  • setDisplayChecksum($display) — Specifies the checksum to be added to the label
    Description
    Setting true will append the checksum to the default label.
    The default value is true.
  • 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($im) — Draws the barcode on the $im
    Description
    The value of the $im argument must be a GD2 image resource. The size of the image can be defined by the value received from getDimension().
  • getDimension($w, $h) — 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($x) — 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 spaces
    Description
    Gets the color of the spaces of the barcode.
    Returns
  • setForegroundColor($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.
  • getBackgroundColor() — Gets the color of the bars
    Description
    Gets the color of the bars of the barcode.
    Returns
  • setBackgroundColor($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.
  • setColor($fg, $bg) — 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($v) — 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($v) — 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.