你可以用Fastreport中的BarCode控件,以下是在一张纸上打印出多个条码的程序:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ppPrnabl, ppClass, ppCtrls, ppBarCod, ppBands, ppCache,
ComCtrls, StdCtrls, ppComm, ppRelatv, ppProd, ppReport, ppTypes;
type
TForm1 = class(TForm)
ppReport1: TppReport;
Button1: TButton;
Button2: TButton;
StatusBar1: TStatusBar;
ppHeaderBand1: TppHeaderBand;
ppDetailBand1: TppDetailBand;
ppFooterBand1: TppFooterBand;
ppBarCode1: TppBarCode;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
g_BarCode: array [0..32] of TppBarCode;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
nColCountBarCode: Integer;
begin
nColCountBarCode := 3;
for i := 0 to 49do
begin
g_BarCode := TppBarCode.Create(Self);
g_BarCode.Band := ppReport1.DetailBand;
g_BarCode.BarCodeType := bcEAN_13;
g_BarCode.AutoSize := False;
g_BarCode.Height := 0.3958;
g_BarCode.Top := g_BarCode.Height * (i div nColCountBarCode) + (i div nColCountBarCode) * 0.2 ;
g_BarCode.Left := g_BarCode.Width * ((i + nColCountBarCode) mod nColCountBarCode) + ((i + nColCountBarCode) mod nColCountBarCode) * 0.5;
g_BarCode.Data := '232323232323';
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with ppReport1do
begin
DeviceType:= dtPrinter;
ShowPrintDialog:=false;
Print;
ShowPrintDialog:=true;
end;
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
var
i: Integer;
begin
for i := 0 to 49do
g_BarCode.Free;
end;
end.