To print a barcode image one approach is to Draw the Picture on the Printer.Canvas, as shown in the code sample below.
Note that the Picture is created in HIMETRIC units, and so to print the image at the correct size these must be converted into printer pixel units using the GetDeviceCaps() function.
procedure TForm1.Button2Click(Sender:
TObject);
var
ii:
integer;
jj:
integer;
Rect:
TRect;
pScalex:
Integer;
pScaley:
integer;
begin
DoBarcode(); {recreate the
barcode image}
{set the target rectangle for
drawing on the printer}
{change from mm to
pixels}
pScalex:=GetDeviceCaps((Printer.Handle),LOGPIXELSX);
pScaley:=GetDeviceCaps((Printer.Handle),LOGPIXELSY);
ii:=(Barcode1.ImageWidth*pScalex) div
2540;
jj:=(Barcode1.ImageHeight*pScaley) div 2540;
Rect.Left:=200;
Rect.Top:=200;
Rect.Right:=Rect.Left+ii;
Rect.Bottom:=Rect.Top+jj;
Printer.BeginDoc;
Printer.Canvas.StretchDraw(Rect,
Barcode1.Picture.Graphic);
Printer.EndDoc;
end;
More: