Listing 15


//Texte drucken: mit Zeilenumbruch sowie Ausgabe von Überschrift und Seitenzahl

procedure PrintText(pTitle: string; pLines: TStrings; pFontName: string; pFontSize: Integer; pFontColor: TColor);
var x, y, cv, vv, cc: Integer;
    sl: TStringList;

begin
sl:=TStringList.Create;
sl.sorted:=False;

   Printer.Canvas.Font.Name:=pFontName;
   Printer.Canvas.Font.Size:=pFontSize;
   Printer.Canvas.Font.Color:=pFontColor;

   for cv:=0 to Printer.Copies-1 do
      with Printer do
      begin
         BeginDoc;

         Canvas.TextOut(Round(20/210*PageWidth), Round(20/297*PageHeight), pTitle);
         Canvas.TextOut(PageWidth-Round(20/210*PageWidth)-Canvas.TextWidth('Seite '+inttostr(PageNumber)), Round(20/297*PageHeight), 'Seite '+inttostr(PageNumber));

         x:=Round(20/210*PageWidth);
         y:=Round(40/297*PageHeight);

         for vv:=0 to pLines.Count-1 do
         begin
            FindToken(pLines[vv], ' ', sl);

            for cc:=0 to sl.Count-1 do
            begin
               if x+Canvas.TextWidth(sl[cc])>PageWidth-Round(20/210*PageWidth) then
               begin
                  x:=Round(20/210*PageWidth);
                  y:=y+Canvas.TextHeight('Wg');
               end;

               if y+Canvas.TextHeight('Wg')>PageHeight-Round(20/297*PageHeight) then
               begin
                  NewPage;
                  Canvas.TextOut(Round(20/210*PageWidth), Round(20/297*PageHeight), pTitle);
                  Canvas.TextOut(PageWidth-Round(20/210*PageWidth)-Canvas.TextWidth('Seite '+inttostr(PageNumber)), Round(20/297*PageHeight), 'Seite '+inttostr(PageNumber));
                  y:=Round(40/297*PageHeight);
               end;

               Canvas.TextOut(x, y, sl[cc]);
               x:=x+Canvas.TextWidth(sl[cc]+' ');
            end;

            x:=Round(20/210*PageWidth);
            y:=y+Canvas.TextHeight('Wg');
         end;

         EndDoc;
      end;

sl.Free;
end;



Zurück zur Hauptseite