HotPDF Barcode Sample

HotPDF Barcode Sample

This HotPDF Component example generates barcode within PDF for 22 popular types.

program Barcodes;
{$APPTYPE CONSOLE}

uses
{$IFDEF VER230} System.Classes, System.SysUtils, Vcl.Graphics,
{$ELSE} Classes, SysUtils, Graphics, {$ENDIF} HPDFDoc;

var
   I, H: Integer;
   HotPDF: THotPDF;

const
  Names: array[0..21] of string =
  (
    'Code 25 Interleaved',
    'Code 25 Industrial',
    'Code 25 Matrix',
    'Code39',
    'Code39 Extended',
    'Code128A',
    'Code128B',
    'Code128C',
    'Code93',
    'Code93 Extended',
    'MSI',
    'PostNet',
    'Codebar',
    'EAN8',
    'EAN13',
    'UPC_A',
    'UPC_E0',
    'UPC_E1',
    'UPC Supp2',
    'UPC Supp5',
    'EAN128A',
    'EAN128B'
    );

begin
  HotPDF:= THotPDF.Create(nil);
  try
    HotPDF.AutoLaunch := true;
    HotPDF.FileName := 'Barcodes.pdf';
    HotPDF.BeginDoc;
    for I := 0 to 7 do
    begin
      for H := 0 to 2 do
      begin
        if ((I * 3) + H) > 21 then Break;
        HotPDF.CurrentPage.DrawBarcode( THPDFBarcodeType((I * 3) + H),    // Draw Black barcode
          H * 266 + 67, I * 133 + 69,       // on the white background
          50, 1, 0, '12345', true, 0, clWhite );  // Draw 12345
        HotPDF.CurrentPage.TextOut( H * 200 + 50, I * 100 + 35, 0, Names[(I * 3) + H] );   // Print barcode name
      end;
    end;
    HotPDF.EndDoc;
  finally
    HotPDF.Free;
  end;
end.
Comments are closed.