Board index » cppbuilder » Tprinter.canvas - TextOut

Tprinter.canvas - TextOut

Does any one know of any good examples on using the Canvas->TextOut() to
print text to a printer canvas?

I am trying to fill a printer's canvas with sample test lines - 66 lines per
page, base on the height of the
printers canvas - such as -

for(int x=1; x<=66; x++)
{
    printer->canvas->TextOut(?,?, String("This is line")+x);

Quote
}

I'm not sure how to calculate the height of each line, and where the next
line should go
Any help would be much appreciated.
Thanks,
Curt
 

Re:Tprinter.canvas - TextOut


Have a look at TCanvas::TextExtent

Gambit

Quote
"Curt Cearley" <cur...@tmscorp.com> wrote in message

news:8cta32$3828@bornews.borland.com...
Quote
> I'm not sure how to calculate the height of each line

Re:Tprinter.canvas - TextOut


The Width and Height Property will tell you the size of the canvas you are
drawing on.
(0,0) is the upper left corner.  (Width, Height) is the lower right corner

int x = 0, y = 0, lineheight;
lineheight = Printer()->Canvas->Height / 66;
x = border; /move x to the right for the margin;
for(int count = 0; count < 66; count++)
  {
  Printer()->Canvas->TextOut(x, y, "This is line" + (String)count);
  y += lineheight;  /move y down the page
  }

Also you can use TextHeight and TextWidth to determine if a specific font
will fit in the space you need. You should take margins into account when
calculating anything, the example above doesn't and I can't guarantee that
it would compile I just quickly wrote it here.

Les

Quote
> Does any one know of any good examples on using the Canvas->TextOut() to
> print text to a printer canvas?

Other Threads