# RPDF417 for Delphi

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

- Introduction
- Installation
- Example
- Methods and Fields of the component

## Introduction

RPDF417 is a Dephi Component that will allow you to create PDF417 barcodes for your Delphi 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.

PDF stands for “Portable Data File.” A two-dimensional symbology (2D), a single PDF417 symbol carries up to 1.1 kilobytes of machine-readable data in a space no larger than a standard bar code. And, unlike one-dimensional bar codes (1D), which are just a key linked to a database, PDF417 symbols contain the database itself. That means, you don't have to store an article number in the barcode but you can also store the name , the size , the color, the name of the manufacturer etc...

RPDF417 support:

- PDF417
- Marco PDF 417. This version allows to concatenate several PDF417 symbols in order to encode larger amount of information.
- Compact/Truncated PDF417. This is a smaller version of PDF417 which can be used in clean environments.

## 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 PDF417.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 pdf417Demo.exe or barcode1D2DDemo.exe.

> In the sample application you can set following properties all PDF and Macro PDF properties. If Segment is not -1, a macro pdf symbol will be created. Otherwise a normal PDF 417 symbol is created.

> You can execute the following commands:

> - Refresh: repaint the symbol using the new properties.
> - Print.
> - Save BMP: save the symbol in bmp format.

## Properties and methods

##

The TPDF417 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 TPDF417 component has the following properties and methods:

> ### Methods

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

>   You can 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;

> - resetMacroPDF(): call this method before rendering a new Macro PDF barcode.
> - prepareMacroPDF(): call this method after resetMacroPDF(). After this method is executed you can read the number of segments required to encode your data. The number of symbols can be read from the pfdMadroSegmenCount Property. For example:

>   > pdf.reseltMacroPDF();
>   > pdf.code:='this is the value to encode';
>   > pdf.prepareMacroPDF();

>   > > {paint all MACRO PDF segments}
>   > > for i=0 to pdf.MacroSegmentCount-1 do begin
>   > > pdf.pdfSegment:=i;
>   > > {paint barcode now}
>   > > pdf.paintBarcode(canvas);
>   > > end;

> ### Properties

> - backColor: background color.
> - barColor: foreground color (color of the bars).
> - barHeightPixels: height in pixels of the bars (default is 7).
> - barWidthPixels: width in pixels of the bars (default is 1).
> - code: string to be encoded.
> - leftmargin: left margin in pixels (default is 10).
> - topMargin: top margin in pixels (default is 10).
> - pdfColumns: number of columns of the PDF417 symbol (default is 10)
> - pdfRows: number of rows of the PDF417 symbol (default is 0). If 0 the number is automatically calulated.
> - pdfMaxRows: maximum number of rows of the PDF417 symbol (optional).
> - pdfECLevel: Error correction level (default is 0). Valid values are 0, 1, 2, 3, 4 and 5.
> - pdfMode: encoding mode (default is PDF_BINARY). Value values are:
>   - PDF_BINARY: can encode any character.
>   - PDF_TEXT: can encode alphanumeric characters and the following punctuation characters: ! \ # $ % & ' ( ) * + , - . / { } | ~
>   - PDF_NUMERIC: encodes digits characters only.
> - pdfTruncated: set it to true in order to create a compact/truncated PDF.

> > Macro PDF properties

> - pdfMacroSegmentCount (read only): number of segments in the macro PDF. This value is calculated by prepareMacroPDF().
> - pdfMacroSegment: Segment of the Macro PDF. Can be a value between 0 and SegmentCount-1.
> - pdfMacroFileName: filename for Macro PDF control block (optional)
> - pdfMacroFileID: file id for Macro PDF control block (optional)
> - pdfMacroFileSize: file size for Macro PDF control block (optional)
> - pdfMacroTimestamp: timestamp for Macro PDF control block (optional)
> - pdfMacroSender: sender for Macro PDF control block (optional)
> - pdfMacroAddresse: addresse for Macro PDF control block (optional)