1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35:
| uses Printers
procedure TForm1.Button1Click(Sender: TObject); var z,zh,s,sb,gr:integer;//zh=zeilenhöhe;sb=spaltenbreite begin If PrintDialog1.Execute then begin Printer.Title:='Text';//angezeigter Text im Druckmanager Printer.Canvas.Font.Size:=7; Printer.BeginDoc; gr:=Printer.Canvas.Font.Height*-1 div Printer.Canvas.Font.size; zh:=0;//Abstand oben For z:=0 to StringGrid1.RowCount-1 do begin sb:=0;//Absand beim Drucken von links For s:=0 to StringGrid1.ColCount-1 do begin //Rechteck Printer.Canvas.Rectangle(sb,zh,sb+StringGrid1.ColWidths[s]*gr,zh+StringGrid1.RowHeights[z]*gr); //Text Printer.Canvas.TextOut(sb+3*gr,zh+3*gr,StringGrid1.Cells[s,z]); sb:=sb+StringGrid1.ColWidths[s]*gr; end; zh:=zh+StringGrid1.RowHeights[z]*gr; If Printer.PageHeight-zh-StringGrid1.RowHeights[z+1]*gr<0 then begin zh:=0;//Abstand oben Printer.NewPage; end; end; Printer.EndDoc; end; end; |