thank you its working now..
but how to print another 3 lines ?? as x, y position on the paper??
In order to make this more straightforward I have defined for my apps the procedures
PrinterWrite and
PrinterWriteln, somewhat similar to the traditional Pascal
write and
writeln procedures.
PrinterWriteln automatically updates the position to begin in a new line.
procedure PrinterWriteln(H: integer; var currentX, currentY: integer;
theString: string; bold: boolean);
begin
if bold then
Printer.Canvas.Font.Style := [fsBold]
else
Printer.Canvas.Font.Style := [];
Printer.Canvas.TextOut(currentX, currentY, theString);
Inc(currentY, H);
end;
procedure PrinterWrite(var currentX, currentY: integer;
theString: string; bold: boolean);
begin
if bold then
Printer.Canvas.Font.Style := [fsBold]
else
Printer.Canvas.Font.Style := [];
Printer.Canvas.TextOut(currentX, currentY, theString);
end;
currentX and
currentY have to be defined by the calling procedure, function or method:
var
gTopMargin, gBottomMargin, gLeftMargin, gRightMargin: double; // these globals might as well be replaced by local or instance variables
gLineSpacing: integer;
procedure TestProcedure;
var
H, ADPI, marginX, marginXr, currentX, currentY, lastY, returnPos, lastPos: integer;
resultLine, remainder: string;
begin
gTopMargin := 2;
gLeftMargin := 2;
gRightMargin := 2;
gBottomMargin := 2;
gLineSpacing := 2;
ADPI := Printer.YDPI;
currentY := GetPoints(gTopMargin, ADPI);
marginX := GetPoints(gLeftMargin, ADPI);
marginXr := GetPoints(gRightMargin, ADPI) div 2;
Printer.Title := 'Test page';
currentX := marginX;
Printer.BeginDoc;
try
Printer.Canvas.Font.Name := gPreferences.PrintFont;
Printer.Canvas.Font.Size := 9;
Printer.Canvas.Font.Style := [];
Printer.Canvas.Pen.Color := clBlack;
Printer.Canvas.Pen.Width := 2;
H := (Printer.Canvas.TextHeight('X') + gLineSpacing);
PrinterWriteln(H, currentX, currentY, 'Caption', True);
PrinterWriteln(H, currentX, currentY, 'Line #1', False);
PrinterWriteln(H, currentX, currentY, 'Line #2', False);
PrinterWriteln(H, currentX, currentY, 'Line #3', False);
Printer.EndDoc;
caseIDBarCode.Destroy;
except
on E: Exception do
begin
Printer.Abort;
raise;
end;
end;
end;