var
tempbitmap:Tbitmap;
printer:Tprinter;
Mystring:string;
begin
Mystring:='我要打印的内容';
tempbitmap:=tbitmap.Create;
printer:=tprinter.Create;
printer.BeginDoc;
with tempbitmap.Canvas do
begin
font.Size:=10;
textout(0,0,Mystring);
CopyRect(rect(0,0,textwidth(Mystring),textheight(Mystring)),
Printer.Canvas,rect(0,0,100,50)); //100,50 是假设的实际宽和高
end;
printer.EndDoc;
tempbitmap.Free;
printer.Free;
end;