和在画布上画差不多
use Printers;
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
xdpi, ydpi: Integer;
begin
xdpi := GetDeviceCaps(Printer.Handle,LOGPIXELSX);
ydpi := GetDeviceCaps(Printer.Handle,LOGPIXELSY);
Printer.Title := 'Printer Test';
Printer.BeginDoc;
with Printer.Canvas do
begin
for i := 1 to 5
begin
MoveTo(xdpi,ydpi*i);
LineTo(xdpi*5,ydpi*i);
MoveTo(xdpi*i,ydpi);
LineTo(xdpi*i,ydpi*5);
end;
end;
Printer.EndDoc;
end;