# RBarcode for Delphi

Copyright J4L (http://www.java4less.com).

- Introduction
- Installation
- Examples
- Methods and Properties

## Introduction

RBarcode is a Delphi component that will allow you to create 1 dimensional barcodes for your windows applications. The component can be used with any Delphi version starting with Delphi 4 (also tested with the most recent Delphi XE5) by simply recompiling the source code.

### Barcodes types

The following is a short description of some of the supported barcode types:

- BAR39: Code 39 is an alphanumeric bar code that can encode decimal numbers, the upper case alphabet, and the following special symbols: _ . * $ / % +. If the checkCharacter flag is set RBarCode will calculate the optional check character (modulus 43).
- BAR39EXT: Extended Code 39 encodes the full 128 character ASCII character. If the checkCharacter flag is set RBarCode will calculate the optional check character (modulus 43).
- INTERLEAVED25: Interleaved 2 of 5 code is a numeric only bar code. If the checkCharacter flag is set RBarCode will calculate the optional modulus 10 check character.
- UPCA: UPC-A is used for marking products which are sold at retail in the USA. Version A encodes a twelve digit number. The first number encoded is the number system character, the next ten digits are the data characters, and the last digit is the check character.
- EAN8: EAN-8 is a shortened version of the EAN-13 code. It includes a 2 or 3 digit country code, 4 of 5 data digits (depending on the length of the country code), and a checksum digit.
- EAN13: The symbol encodes 13 characters: the first two or three are a country code which identify the country in which the manufacturer is registered (not necessarily where the product is actually made). The country code is followed by 9 or 10 data digits (depending on the length of the country code), and a checksum digit.
- UPCE: The UPC-E code is a compressed barcode which is intended for use on small items. Compression works by squeezing extra zeroes out of the barcode and then automatically re-inserting them at the scanner. Only barcodes containing zeroes are candidates for the UPC-E symbol.
- CODE128: Code 128 is a continuous, multilevel, full ASCII code. If the checkCharacter flag is set RBarCode will calculate the mandatory check character (modulus 103).
- EAN128: modified version of code128 starting with the control character FNC1.
- MSI: MSI Code is a numeric. If the checkCharacter flag is set RBarCode will calculate the modulus 10 check character.
- CODE11: Code 11 is a numeric, high density code with one special character - .If the checkCharacter flag is set RBarCode will calculate check character. If the value to be encoded is longer than 10 digits, a second check character will be calculated.
- CODE93: Code 93 is a more compact version of Code 39. It encodes exactly the same characters as Code 39, but uses 9 barcode elements per character instead of 15. If the checkCharacter flag is set RBarCode will calculate the optional modulus 43 check character .
- IND25: Industrial 2 of 5 is a numeric-only barcode that has been in use a long time. Unlike Interleaved 2 of 5, all of the information is encoded in the bars; the spaces are fixed width and are used only to separate the bars. The code is self-checking and does not include a checksum.
- CODABAR: Codabar is a discrete, numeric code with special characters (-$:/.+). If the checkCharacter flag is set RBarCode will calculate the optional modulus 16 check character .

At HP site you will find more information abour barcode.

## Installation

There are 2 installation possibilities ActiveX version and Delphi source code.

In order to install the ActiveX version of the control:

1. select main menu -> component -> import activeX control
2. click on "Add...", select RBarcodeDX.ocx file
3. You will now see: TBarcode1DX, TDatamatriX, TDPF417X and TMaxicodeX in the "Classes" window.
4. click on "Install", install window will come up.
5. click "ok" to install
6. the controls will appear in the "ActiveX" tab of the components palette.

In order to install from the Delphi source code (registered users only):

1. select main menu -> component -> install component
2. click on "browse" and select Barcode1D.pas
3. click "ok"
4. the control will appear in the "Barcodes" tab of the components palette.

## Examples

In order to run the sample application you must execute barcode1DDemo.exe or barcode1D2DDemo.exe.

## Properties and methods of the component

The TBarcode1D component is a subclass of TGraphicControl and can therefore be placed on any form or container. This is the esiest way to use it , however you can also create an instance of the component by program and then paint the barcode on any canvas object using the paintBarcode() method.

The TBarcode1D component has following properties and methods:

> ### Methods

> - paintBarcode(canvas): pains the barcode on the provided canvas.

>   You can also use the component in order to paint onto an external canvas. For example, in order to create a bitmap file you would use the following code:

>   > var
>   > bmp: TBitmap;
>   > begin
>   > bmp:=TBitmap.create();
>   > bmp.height:=200;
>   > bmp.width:=200;
>   > {use paintBarcode() to paint onto an external Canvas}
>   > barcode.paintBarcode(bmp.Canvas);

>   > bmp.saveToFile('barcode.bmp');
>   > end;

> ### Properties

> - barType: this is the type of barcode to be used. Valid values are: CODE39 ,CODE39EXT , CODE11 ,INTERLEAVED25, CODABAR , CODE93, CODE93EXT , CODE128 ,EAN128, MSI , MAT25 ,IND25, EAN13 , EAN8 , POSTNET, UPCA and UPCE .
> - backColor: background color of the barcode.
> - barColor: color of the bars.
> - barHeightPixels:: height of the bars in pixels. If this value is 0, it will be calculated using H.
> - barpostnetHeightTallBar: height (in pixels) of PostNet's tall bar.
> - barpostnetHeightShortBar: height (in pixels) of PostNet's short bar.
> - CODABARStartChar: Start character for CODABAR. Valid values are 'A', 'B', 'C' or 'D'.
> - CODABARStopChar: Stop character for CODABAR. Valid values are 'A', 'B', 'C' or 'D'.
> - code: this is the value to be encoded.
> - codeText: text to be displayed with the barcode.
> - code128set: set of charaters to be used in code128. Valid values are : code128A (0), code128B (1) and code128C (2).
> - checkCharacter : If true the software will calculate the check character automatically.
> - Font: font used to display the code.
> - guardBars: indicates if guardbars will be height than other bars. Only for EAN and UPC.
> - H: Indicates how to calculate the height of the bars. A value of 0.5 means that the bars should be half the length of the symbol.
> - I: intercharacter separator , only for CODE39. A value of 1 means that the separator will have the same length as X.
> - leftMargin: left margin in pixels.
> - N: a value of 2, means that wide bars will be 2 times the width of narrow bars. The default vaue is 2.
> - processTilde: process the " ~ " in the string to be encoded. The format is ~dNNN where NNN is a value between 0 and 255.
> - supHeight: relative height of the supplement's bars (only EAN and UPC). The default (0.8) means 80% of the normal bars.
> - supSeparation: separation between the code and the supplement (in pixels). the default is 10(only EAN and UPC).
> - supplement: barcode suplement, can be 2 or 5 digits (for EAN and UPC only)..
> - topMargin: top margin in pixels.
> - textOnTop: if true the text will be place above the barcode.
> - UPCEANSupplement2: indicates if the codes EAN and UPC will have a 2 digit's supplement.
> - UPCEANSupplement5: indicates if the codes EAN and UPC will have a 5 digit's supplement.
> - UPCESystem: encoding system to be used for UPCE, valid values are '0' and '1'.
> - X: width in pixels of narrow bars. The default is 1.

> ### How to use the checkCharacter property:

> If you are suppling the code with the check digit already calculated, you must set checkCharacter to false (this is the default). If you want the software to calculate the checksum for you, you must set barcheckCharacter to true.

> For EAN and UPC have fixed length and therefore you only have the following possibilities:

> - EAN13: you supply a 13 digits code and set barcheckCharacter to false or you supply a 12 digits code and set barcheckCharacter to true.
> - EAN8: you supply a 8 digits code and set barcheckCharacter to false or you supply a 7 digits code and set barcheckCharacter to true.
> - UPCA and UPCE: you supply a 12 digits code and set barcheckCharacter to false or you supply a 11digits code and set barcheckCharacter to true.