LazBarcodes

From Lazarus wiki
Revision as of 19:03, 11 March 2022 by Wp (talk | contribs) (2-of-5 Barcodes)
Jump to navigationJump to search

General

lazbarcodes demo.png

About

LazBarcodes is a set of controls to create 1D and 2D barcodes. The backend engine is a port of Zint at sourceforge. Some units were heavily refactored to obtain a more Pascal-like code.

The library supports the generation of 1D and 2D barcodes:

  • 1D barcodes: Code-11, Code-128, Channel code, EAN-128, several 2-of-5 variants, several 3-of-9 variants, EAN, UPC, Plessey, MSI/Plessey, Telepen, medical/pharmaceutical codes (CodaBar, Code-32, Pharma one-track, Pharma two-track, PZN), postal codes (Australian post, Japanese post, Korean Post, Deutsche Post IdentCode and LeitCode, Dutch KIX, Planet, PostNet, Royal Mail RM4SCC)
  • 2D barcodes: QR, MicroQR, Aztec, Aztec Rune, Data Matrix, PDF417

Author

2011 - Jose Mejuto

License

BSD 3 as it is being inherited from the zint source code.

Dependencies / System Requirements

  • None


Getting LazBarcodes

The download contains the packages lazbarcodes and lazbarcodes_runtimeonly. The first one gives you visual components of the above barcodes and the second can be used just to access the ported zint code for advanced barcode generation.

Development version

The latest source code can be found on Lazarus-CCR. Use SVN to load the source files, or download the "Snapshot" by clicking on the corresponding button of the sourceforge site and unzip it to some directory. For installation go to "Package" > "Load package file (*.lpk)", navigate to the folder with the downloaded sources and load the fole lazbarcodes_runtimeonly.lpk. Then load the package lazbarcodes.lpk. Click "Use" > "Install", and confirm the question to rebuild the IDE. After some time the IDE restarts, and you find the barcodes in the "LazBarcodes" tab of the component palette.

Release version

Occasionally a release version is prepared and made available for easy installation by means of the Online-Package-Manager in the Lazarus IDE. Open "Package" > "Online package manager", check the item "LazBarcodes" in the list and click "Install". Again, confirm the question to rebuild the IDE. When the IDE restarts after some time you find the barcodes in the "LazBarcodes" tab of the component palette.

Change Log

  • v2.0.0: Added a lot of 1D barcodes
  • v1.0.3: Internally used units renamed to avoid naming conflict with CodeTyphon package PL_APE.
  • v1.0.2: Change of license from GPL to BSD
  • Initial development.

Documentation

General

The components installed by the LazBarcodes package descent from TGraphicControl and thus inherit fundamental control properties such as Width, Height, AutoSize, etc. They share a variety of other properties and methods; some properties, however, are not published fwhen they are not appropriate for the current barcode type.

Properties

  • Text: TCaption - Text to be encoded as a barcode. Note that, depending on the barcode type, there exist limitations on allowed text length and allowed characters.
  • ShowHumanReadableText: Boolean - Displays the encoded text underneath the barcode symbol. Note that the encoding algorithm may add check sum or additional characters to the input text.
  • BarcodeType - Some barcode components can be modified to create various symbologies by selecting the corresponding value in this (type-dependent) enumeration.
  • Scale: Integer - Horizontal scaling factor of the barcode determining the width of the smallest feature (bar or space) in pixels. Scale=0 tries to select an internal scale value such that the barcode fills the control's width as much as possible. Note that this scaling factor applies to all bars and spaces and therefore, increasing Scale does not increase the barcode with gradually but by more or less large steps.
  • SymbolHeight: Integer - Similar to Scale, but refers now to the vertical direction. Again, SymbolHeight=0 fills adjusts the internal symbol height to fill the height
  • MinSymbolHeight: Integer - Prevents the symbol to become too small.
  • RecommendedSymbolSize: Boolean - If true, overrides the Scale and SymbolHeight settings so that the size of the symbol is as close as possible to its specification.
  • AutoSize: Boolean - inherited standard property. When true, Width and Height are selected such that the current size of the barcode is enclosed. Note that AutoSize=true is ignored when Scale=0 or SymbolHeight=0.
  • Margin: Integer - Amount of empty pixels added around the symbol
  • WhitespaceWidth: Integer - Amount of empty pixels added to the left and right of some symbologies to enhance readability of barcode scanners.
  • BearerBarMode: TBearerBarMode = (bbmNone, bbmBearerBars, bbmBox) - adds horizontal bars above and below the barcode (bbmBearerBars) or a box around the barcode (bbmBox). The thickness of the bars and the box border is given by the Margin multiplied by the currently used internal Scale parameter.
  • ForegroundColor: TColor - Color used to draw the bars
  • BackgroundColor: TColor - Color used to draw the background of the barcode (spaces, margin and text area).

Methods

  • CopyToClipboard - Copies the barcode to the clipboard as a bitmap
  • SaveToFile(const AFileName: String; AImageClass: TFPImageBitmapClass) - Saves the barcode as a graphic image of the specified class to file.
  • SaveToStream(const AStream: TStream; AImageClass: TFPImageBitmapClass) - Saves the barcode as a graphic image of the specified class to a stream.
  • SaveToEPSFile(const AFileName: String) - Saves the barcode as EPS file
  • SaveToEPSStream(const AStream: TStream) - Saves the barcode in EPS format as stream.
  • SaveToSVGFile(const AFileName: String) - Saves the barcode in SVG format to file
  • SaveToSVGStream(const AStream: TStream) - Saves the barcode in SVG format to as stream
  • ErrorString: String - In case of an error, this read-only property contains a message why the Text could not be encoded correctly.

Components

Component BarcodeType Name Application Allowed chars Text length Reference
TBarcodeC11
tbarcodec11.png
Code-11 Telecommunication '0'..'9', '-' up to 121 https://en.wikipedia.org/wiki/Code_11
TBarcodeC128
tbarcodec128.png
bctC128 Code-128 Industrial applications #0..#127 up to 160 https://en.wikipedia.org/wiki/Code_128
bctEAN128 EAN-128, or
GS1-128
Industrial applications #0..#127 Depending on "Application identifier"
to be given in square parenthesis
https://en.wikipedia.org/wiki/GS1-128]
TBarcode2of5
tbarcode2of5.png
bctCode25Standard Standard 2-of-5, or
Matrix 2-of-5
Warehouse sorting
photo finishing
airline ticket marking
'0'..'9' up to 80 https://en.wikipedia.org/wiki/Matrix_2_of_5
bctCode25DataLogic DataLogic 2-of-5 Processing and sorting of mail
for the Chinese Postal Service
'0'..'9' up to 80 https://en.wikipedia.org/wiki/Matrix_2_of_5
bctCode25IATA IATA 2-of-5 Airline Cargo '0'..'9' up to 45 https://en.wikipedia.org/wiki/Industrial_2_of_5#IATA_2_of_5
bctCode25Industrial Industrial 2-of-5 Cardboard printing
photo developing envelopes
warehouse sorting systems
'0'..'9' up to 45 https://en.wikipedia.org/wiki/Industrial_2_of_5
bctCode25Interleaved Interleaved 2-of-5 135 film
cartons of some products
'0'..'9' up to 89 https://en.wikipedia.org/wiki/Interleaved_2_of_5
bctITF14 ITF-14 Packaging levels of a product '0'..'9' up to 13 https://en.wikipedia.org/wiki/ITF-14

TLazBarcodeC11

1D barcodes

  • tbarcodec11.png TBarcodeC11:
    • Code-11: max 121 numeric characters ('0'..'9')
  • tbarcodec128.png TBarcodeC128: Property BarcodeType allows to select one of the subsets:
  • tbarcode3of9.png TBarcode3of9: supports the following subsets via property BarcodeType:
    • bctCode39: Code 3-of-9 (C39) - up to 74 characters: numeric, uppercase-alpha and some special characters (-. $/+%abcd).
    • bctCode39Ext: Extended Code 3-of-9 (C39+) - up to 74 characters, all ASCII characters allowed (< #128).
    • bctLOGMARS: LOGMARS - like C39, different wide bar width.
    • bctCode93: Code-93 - up to 107 characters like C39.
  • tbarcodeean.png TBarcodeEAN: supports the following subsets via property BarcodeType:
    • bctEAN: EAN-8 and EAN-13 - up to 13 numeric digits
    • bctEAN14: EAN-14 - up to 13 numeric digits
    • bctISBN: ISBN - 9, 10 or 13 numeric characters or 'X'
    • bctNVE18: NVE-18 - up to 25 numeric digits
    • bctUPCA: UPC-A - up to 10 numeric digits (plus 2 check digits)
    • bctUPCE: UPC-E - up to 7 numeric digits

2D barcodes

The download contains the packages "lazbarcodes" and "lazbarcodes_runtimeonly". The first one gives you visual components of the above barcodes and the second can be used just to access the ported zint code for advanced barcode generation.

Screenshot

lazbarcodes demo.png

Author

2011 - Jose Mejuto

License

BSD 3 as it is being inherited from the zint source code.

Download

The latest source code can be found on Lazarus-CCR

Change Log

  • v2.0.0: Added a lot of 1D barcodes
  • v1.0.3: Internally used units renamed to avoid naming conflict with CodeTyphon package PL_APE.
  • v1.0.2: Change of license from GPL to BSD
  • Initial development.

Dependencies / System Requirements

  • None

Status: In development

Issues: None by now.

Installation

  • Step 1: Compile the package "lazbarcodes_runtimeonly".
  • Step 2: Install the package "lazbarcodes".

Final notes

If you need the generation of another barcode and it is present in Zint, please ask for it in the Lazarus forum or mailing lists.