printing a tmemo correctly
"uri" <[email protected]> Mon, 30 Sep 2002 09:45:57 -0000
| Newsgroups | gmane.comp.lang.delphi.kylix |
|---|---|
| Message-ID | <[email protected]> |
hi everyone, i ran into a problem and i can't really figure it out, i
have a tmemo and i need to print the text in it, taking into account
the font.
i'm using the code at the end of this message, but this code will
print only the 1st page, not knowing how to handle the rest, also it
doesn;t respect the font settings.
i'm using kylix 2 open edition and i couldn't find any component to
print. i'm using QPrinters. but still.
any ideas? any help will be greatly appreciated
procedure PrintTStrings(Lst : TStrings) ;
var
I,
Line : Integer;
begin
I := 0;
Line := 0 ;
Printer.Canvas.Font:=ActiveRich.Font;
Printer.BeginDoc ;
for I := 0 to Lst.Count - 1 do begin
Printer.Canvas.TextOut(0, Line, Lst[I]);
{Font.Height is calculated as -Font.Size * 72 / Font.PixelsPerInch
which returns
a negative number. So Abs() is applied to the Height to make it a
non-negative
value}
Line := Line + Abs(Printer.Canvas.Font.Height);
if (Line >= Printer.PageHeight) then
begin
Printer.NewPage;
end;
end;
Printer.EndDoc;
end;