var
PtrRect,
formRect: TRect;
textPosY: Integer;
midY, textLeft, newTextXoffset, newLineOffset: Integer;
forPrint: Boolean;
scaleFactor : Single;
PpageW : Integer;
PPageH : Integer;
begin
formRect.Left := 0;
formRect.Top := 0;
formRect.Right := formImage.Width;
formRect.Bottom := formImage.Height;
{on an A4 laser printer the width in 'pixels' of a printer page
is 4799 (almost 4800) which is 10 x the height of a standard VGA
screen, but of course printer properties vary widely, so in order
to be sure we code for any printer we need to be careful about the
way we scale things...}
{the area in which we want to print the designed style image,
leaving room for text below half-way on the page, is calculated like
this:
PageWidth - borders, and
PageHeight /2 - one border...}
PpageW := Printer.PageWidth - Printer.PageWidth div 6;
PPageH := (Printer.PageHeight div 2) - Printer.PageHeight div 12;
if (PpageW / formImage.Width) < (PPageH / formImage.Height) then
scaleFactor := PpageW / formImage.Width
else
scaleFactor := PPageH / formImage.Height;
PtrRect.Left := (Printer.PageWidth div 2) - Round((formImage.Width div 2) * scaleFactor);
PtrRect.Top := Printer.PageHeight div 12;
PtrRect.right := (Printer.PageWidth div 2) + Round((formImage.Width div 2) * scaleFactor);
PtrRect.bottom := (Printer.PageHeight div 12) + Round(formImage.height * scaleFactor);
{and later...}
with Printer do
begin
Canvas.StretchDraw(PtrRect, formImage.Picture.Graphic);