function TCustomPrinter.PrintText(Xmm, Ymm: Extended; Txt: string;
FontSize: Integer=10;AllowNewLine:Boolean=False):Integer;
var
Px, Py: Integer;
begin
Result:=1;
Xmm := Xmm + FiOffSetX/10;
Ymm := Ymm + FiOffSetY/10;
Px := Round(Round(Xmm * HPointsPerInch * 10000/25.4) / 10000);
Py := Round(Round(Ymm * VPointsPerInch * 10000/25.4) / 10000);
Py := Py - GetOffSetY; //因为是绝对坐标, 因此, 不用换算成相对于Y轴坐标
Px := Px + 2 * AvgCharWidth;
Printer.Canvas.Font.Name := ''宋体'';
Printer.Canvas.Font.Size := FontSize;
//Printer.Canvas.Font.Color := clGreen;
if not Printer.Aborted then
Printer.Canvas.TextOut(Px, Py, Txt);
end;
Procedure TCustomPrinter.PrintChar(s: PChar);
var
tf: TextFile;
begin
AssignFile(tF, ''LPT1'');
Rewrite(tF);
Write(tF,s);
CloseFile(tF);
end;
procedure TCustomPrinter.PrintEllipse(Xmm1, Ymm1, Xmm2, Ymm2: DOUBLE;APenWidth: Integer=2);
var
oldPen: TPen;
Px1, Py1, Px2, Py2 : Integer;
begin
oldPen:=TPen.Create;
OldPen.Assign(Printer.Canvas.Pen);
Xmm1 := Xmm1 + FiOffSetX/10;
Ymm1 := Ymm1 + FiOffSetY/10;
Xmm2 := Xmm2 + FiOffSetX/10;
Ymm2 := Ymm2 + FiOffSetY/10;
Px1 := Round(Round(Xmm1 * HPointsPerInch * 10000/25.4) / 10000);
Py1 := Round(Round(Ymm1 * VPointsPerInch * 10000/25.4) / 10000);
Py1 := Py1 - GetOffSetY; //因为是绝对坐标, 因此, 不用换算成相对于Y轴坐标
Px1 := Px1 + 2 * AvgCharWidth;
Px2 := Round(Round(Xmm2 * HPointsPerInch * 10000/25.4) / 10000);
Py2 := Round(Round(Ymm2 * VPointsPerInch * 10000/25.4) / 10000);
Py2 := Py2 - GetOffSetY; //因为是绝对坐标, 因此, 不用换算成相对于Y轴坐标
Px2 := Px2 + 2 * AvgCharWidth;
// Printer.Canvas.Font.Name := ''宋体'';
// Printer.Canvas.Font.Size := 10; // FontSiz