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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| Procedure TForm5.Imprime(Sender: TObject;ligne_debut, ligne_fin, page, total_pages : integer);
var
r : TRect;
i : Integer;
begin
with Printer do
begin
r := Rect(0,0, Pagewidth, PageHeight);
BeginDoc;
Canvas.Brush.Style := bsClear;
Canvas.font.Size := 12;
Canvas.TextOut(1000,50 , 'LISTE des ARTICLES présents dans la base');
if total_pages = 1 then
begin
Canvas.TextOut(50,100 , 'En date du'+ DateToStr(now));
Canvas.TextOut(2550,100 , 'page 1/1');
//ligne horizontale haut n°2
Canvas.MoveTo(10,180);
Canvas.LineTo(3000,180);
Canvas.font.Size := 10;
for i := ligne_debut to ligne_fin do
Canvas.TextOut(50,200 + (i *Canvas.TextHeight(RichEdit1.Lines.Strings[i])),
RichEdit1.Lines.Strings[i]);
Canvas.Brush.Color := clBlack;
Canvas.FrameRect(r);
end
else
begin
Canvas.TextOut(50,100 , 'En date du : '+ DateToStr(now));
Canvas.TextOut(2550,100 ,' page '+ IntToStr(page) + '/' + IntToStr(total_pages));
//ligne horizontale haut n°2
Canvas.MoveTo(10,180);
Canvas.LineTo(3000,180);
Canvas.font.Size := 10;
for i := ligne_debut to ligne_fin do
Canvas.TextOut(50,200 + (i *Canvas.TextHeight(RichEdit1.Lines.Strings[i])),
RichEdit1.Lines.Strings[i]);
Canvas.Brush.Color := clBlack;
Canvas.FrameRect(r);
end;
EndDoc;
end;
end;
{**********}
procedure TForm5.ImpListeClick(Sender: TObject);
var
nb_total_pages,page,first_line,last_line : integer;
// impression de la liste des clients
begin
if (PrintDialog1.Execute) and (RichEdit1.Lines.Count <> 0) then
begin
nb_total_pages := (RichEdit1.Lines.Count div 80) + 1;
page := 1;
first_line := 0;
while nb_total_pages > page do
begin
last_line := first_line + 80;
Imprime(Sender,first_line, last_line, page, nb_total_pages);
inc(page);
inc(first_line,80);
end;
last_line := RichEdit1.Lines.Count; // dernière page
Imprime(Sender,first_line, last_line, page, nb_total_pages);
end
else exit;
end;
{**********} |
Partager