请试试(我已试过可以):
procedure TForm1.Button1Click(Sender: TObject);
begin
with Printer do
begin
BeginDoc;
with Canvas do
begin
if SetMapMode(Handle,MM_TEXT)=0 then //逻辑坐标为打印机点坐标
ShowMessage('Failed: SetMapMode(Handle,MM_TEXT)');
Pen.Width := 1;
Pen.Color := clBlack;
Brush.Style := bsClear;
Rectangle(100,100,500,400); //画一个40x30(点)的矩形
MoveTo(150,150);
LineTo(450,350);
TextOut(110,110,'40x30(点)');
if SetMapMode(Handle,MM_LOMETRIC) = 0 then //每一逻辑点为0.1MM,注意Y轴方向向下
ShowMessage('Failed: SetMapMode(Handle,MM_LOMETRIC)');
Pen.Width := 1;
Pen.Color := clBlack;
Brush.Style := bsClear;
Rectangle(100,-100,500,-400); //画一个40MMx30MM的矩形
MoveTo(150,-150);
LineTo(450,-350);
TextOut(110,-110,'40MMx30MM');
end;
EndDoc;
end;
end;