Re: Printing - How to?

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Tue, 06 Feb 2001, Tony Steward wrote:
> Hi all,
> I am trying to create a print procedure for my program, following is my 
> code but it all prints on one line. How do I send line feeds. Or am i 
> doing something else wrong.
> Also
> How can i tell if the text is too long for a line?
> How would i know when to start a new page?

You have to determine the page size and the font size, and keep track 
of how much page is left after each line is printed. Here's a snippet of 
code - not neat, but it has been working for a couple of years without 
fail :^)

Regards,
Irv
result = getFontSize(Printer)
fontY = result[2]
result = getExtent(Printer)
pageY = result[2]
y  = 0
header[1] = sprintf(tab(90)&"Page %d",pg)
pg += 1
doc = header & doc
while True do
 if length(doc) = 0 then exit
 end if
if y + fontY > pageY then exit
 end if
setPosition(Printer, 0, y) -- note!
wPuts(Printer,doc[1])
doc = doc[2..length(doc)]
y += fontY
end while
if not endPage() then printErr = True
end if
return doc
end function

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu