Manual - Code 39 Extended

Introduction

Code 39 Extended version allows you to write all the ASCII characters from 0 to 127 thanks to the special characters provided by the Code 39. These characters are "$/+%". Since the extended version of Code 39 is optional, you have to check your reader to see if it supports Code 39 Extended. Otherwise, the decoded code will be different from your input.

This class inherits the BCGcode39 class.

Example

Methods

BCGcode39extended's Methods

  • No specific methods for this class.

BCGcode39's Methods

BCGBarcode1D's Methods

BCGBarcode's Methods

Code Example

'use strict';

import { createServer } from 'http';
import {
    BCGColor,
    BCGDrawing,
    BCGFont,
    BCGLabel,
    createSurface,
    toBuffer
} from '@barcode-bakery/barcode-nodejs';
import { BCGcode39extended } from '@barcode-bakery/barcode-nodejs/1d';

http.createServer(function (request, response) {
    const font = new BCGFont('Arial', 18);
    const colorBlack = new BCGColor(0, 0, 0);
    const colorWhite = new BCGColor(255, 255, 255);

    // Barcode Part
    const code = new BCGcode39extended();
    code.setScale(2); // Resolution
    code.setThickness(30); // Thickness
    code.setForegroundColor(colorBlack); // Color of bars
    code.setBackgroundColor(colorWhite); // Color of spaces
    code.setFont(font); // Font
    code.parse('Ab39');

    // Drawing Part
    const drawing = new BCGDrawing(createSurface);
    toBuffer(drawing, BCGDrawing.ImageFormat.Png, function (err, buffer) {
        response.writeHead(200, { "Content-Type": "image/png" });
        response.end(buffer);
    });
}).listen(8124);

Method explanations

  • setChecksum(checksum) — Specifies if a checksum must be added
    Description
    Specifies if a checksum must be added.
  • 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.
  • 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.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 for the label.
    Returns
  • setFont(font) — Sets the text font for the label
    Description
    The value of the argument must be an instance of the BCGFontFile class.
  • 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(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.