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 36 37 38 39 40
| procedure TForm2.Button1Click(Sender: TObject);
var
Line,H : integer;
MyPrinter: TPrinter;
compteur,compteur2,i : integer;
begin
if PrintDialog1.Execute then
begin
i:=0;
compteur2:=0;
Compteur := 0;
MyPrinter := Printer;
MyPrinter.BeginDoc;
MyPrinter.Canvas.Font.Name := 'Arial';
MyPrinter.Canvas.Font.Size := 7;
H := MyPrinter.Canvas.TextHeight('Gg') + 2;
PrintDialog1.PrintRange := prAllPages ;
for Line := 0 to Listbox8.Items.Count-1 do
begin
inc(Compteur);
if (Compteur = 99) OR (Compteur = 198) OR (Compteur = 297) OR (Compteur = 396) OR (Compteur = 495)then
MyPrinter.NewPage;
MyPrinter.Canvas.TextOut(25, 25 + Line * H, ListBox8.Items.Strings[Line]);
MyPrinter.Canvas.TextOut(250, 25 + Line * H, ListBox2.Items.Strings[Line]);
MyPrinter.Canvas.TextOut(2000, 25 + Line * H, ListBox3.Items.Strings[Line]);
MyPrinter.Canvas.TextOut(2300, 25 + Line * H, ListBox4.Items.Strings[Line]);
MyPrinter.Canvas.TextOut(3300, 25 + Line * H, ListBox5.Items.Strings[Line]);
MyPrinter.Canvas.TextOut(3600, 25 + Line * H, ListBox6.Items.Strings[Line]);
MyPrinter.Canvas.TextOut(4400, 25 + Line * H, ListBox7.Items.Strings[Line]);
end;
{ for i := i to Compteur2 do cette boucle est un autre essai
MyPrinter.NewPage; } mais imprime que des pages blanches à la fin
MyPrinter.EndDoc;
end;
end; |
Partager