Anyone who needs to know how to generate barcode in Delphi application needs look no further. Barcodesoft Encoder is a smart and simple solution to generate linear and two-dimensional barcode in your own Delphi application.
1. Create a new VCL Forms application. Add a TButton and a TMemo.
TMemo is able to display 2D barcode because 2D barcode contains multiple lines of texts.
2. Type in the following DOS command to register crUFLbcs.dll
regsvr32 crUFLbcs.dll
If registration fails, please use the following DOS command to register it.
Regtlibv12 is a utility of Windows .NET Framework 2.0.
Regtlibv12 _cruflbcs.tlb
3. Click menu Component ==> Import Component, then choose Type Library and click Next button as shown below.
Add cruflBCS_TLB in uses section before add code snippet to your button onclick event handler.
Click Add button and choose cruflbcs.dll from C:\Program Files (x86)\Common Files\Barcodesoft\FontUtil folder.
Or C:\Program Files (X86)\Common Files\Barcodesoft\FontUtil folder on 64-bit systems.
For linear barcode:
such as code39, code128, GS1-128 (UCC/EAN-128), UPC-A, EAN13 etc. Please copy and modify the following code snippet.
For Code39 Barcode:
procedure TForm1.Button1Click(Sender: TObject);
var
I :ILinear;
str : WideString;
begin
I := CoCLinear.Create;
str := I.Code39('BARCODE DELPHI');
Memo1.Text := str;
Memo1.Font.Name := 'Code39mHr';
end;
For Code128 Barcode:
procedure TForm1.Button1Click(Sender: TObject);
var
I :ILinear;
str : WideString;
begin
I := CoCLinear.Create;
str := I.Code128A('BARCODE DELPHI');
Memo1.Text := str;
Memo1.Font.Name := 'Code128AmHr';
end;
For GS1-128 Barcode:
procedure TForm1.Button1Click(Sender: TObject);
var
I :ILinear;
str : WideString;
begin
I := CoCLinear.Create;
str := I.UCCEAN128('011234567890123456');
Memo1.Text := str;
Memo1.Font.Name := 'Code128m';
end;
For UPCA Barcode:
procedure TForm1.Button1Click(Sender: TObject);
var
I :ILinear;
str : WideString;
begin
I := CoCLinear.Create;
str := I.UPCA('12345678901');
Memo1.Text := str;
Memo1.Font.Name := 'UpcEanM';
end;
For Intelligent Mail Barcode:
procedure TForm1.Button1Click(Sender: TObject);
var
I :ILinear;
str : WideString;
begin
I := CoCLinear.Create;
str := I.IM('Intelligent Mail BARCODE DELPHI');
Memo1.Text := str;
Memo1.Font.Name := 'BcsIM';
end;
For GS1-Databar Barcode:
procedure TForm1.Button1Click(Sender: TObject);
var
I :IDatabar;
str : WideString;
begin
I := CoCDatabar.Create;
str := I.Databar14('GS1-Databar DELPHI');
Memo1.Text := str;
Memo1.Font.Name := 'BcsDatabarM';
end;
For 2D Barcode:
such as PDF417, Data Matrix, QR Code, Aztec code, MaxiCode and Code16K. Please copy and modify the following code snippet.
For PDF417 barocde:
procedure TForm1.Button1Click(Sender: TObject);
var
I : IPDF417;
str : WideString;
begin
I := CoCPDF417.Create;
str := I.Encode('PDF417 Barcode Delphi');
Memo1.Text := str;
Memo1.Font.Name := 'BcsPdf417';
end;
For Data Matrix barcode:
procedure TForm1.Button1Click(Sender: TObject);
var
I : IDataMatrix;
str : WideString;
begin
I := CoCDataMatrix.Create;
str := I.Encode('Delphi Data Matrix Barcode');
Memo1.Text := str;
Memo1.Font.Name := 'BcsDatamatrix';
end;
For QR Code barcode:
procedure TForm1.Button1Click(Sender: TObject);
var
I : IQRCode;
str : WideString;
begin
I := CoCQrcode.Create;
str := I.Encode('QRCode Barcode Delphi');
Memo1.Text := str;
Memo1.Font.Name := 'BcsQrcode';
end;
For Aztec Barcode:
procedure TForm1.Button1Click(Sender: TObject);
var
I : IAztec;
str : WideString;
begin
I := CoCAztec.Create;
str := I.Encode('Aztecd Barcode Delphi');
Memo1.Text := str;
Memo1.Font.Name := 'BcsAztec';
end;
For MaxiCode Barcode:
procedure TForm1.Button1Click(Sender: TObject);
var
I : IBCSMaxiCode;
str : WideString;
begin
I := CoCMaxiCode.Create;
str := I.Encode('Maxicode Barcode Delphi');
Memo1.Text := str;
Memo1.Font.Name := 'BcsMaxicode';
end;
For Code16K Barcode:
procedure TForm1.Button1Click(Sender: TObject);
var
I : ICode16K;
str : WideString;
begin
I := CoCCode16K.Create;
str := I.Encode('Code16K Barcode Delphi');
Memo1.Text := str;
Memo1.Font.Name := 'Code16Km';
end;
You can modify these codes and start playing around from here.
|