1. Breaking text when printing
- Posted by "EU Coder" <eucoder at hotmail.com> Aug 02, 2004
- 512 views
Hi, I have a RichEdit control and I am printing text from it fine. But when I type into the control without breaking the text, it prints the text in one long line that runs off the page. Is there a simple way to fix this so when I print long lines it breaks the text to a new line? Thank you
2. Re: Breaking text when printing
- Posted by Derek Parnell <ddparnell at bigpond.com> Aug 02, 2004
- 479 views
EU Coder wrote: > > Hi, > > I have a RichEdit control and I am printing text from it fine. But when I > type into the control without breaking the text, it prints the text in one > long line that runs off the page. Is there a simple way to fix this so when > I print long lines it breaks the text to a new line? Look up the docs for the drawText() routine. This has automatic word-wrapping and a few other tricks. -- Derek Parnell Melbourne, Australia
3. Re: Breaking text when printing
- Posted by "EU Coder" <eucoder at hotmail.com> Aug 02, 2004
- 527 views
Thank you Derek I tried your suggestion, but when the page prints I get a sequence of numbers instead of the text. I have included the test code im using ------------------------------------------------------------------------- constant CrLf = { '\r', '\n' }, Lf = { '\n' } integer printErr sequence result -- is the document empty? if length( doc ) = 0 then -- do nothing return doc end if -- start a new page if not startPage() then -- set error and return empty sequence printErr = True return {} end if -- get the attributes of font result = getFontSize( Printer ) fontY = result[2] -- get the attributes of the page result = getCtlSize( Printer ) pageY = result[2] -- start at top of page y = 0 z = 1 while z <= length(doc) do -- out of space? if y + fontY > pageY then exit end if -- print on page setPenPosition( Printer, 0, y ) wPuts( Printer, doc[z]) -- move down a line y += fontY z += 1 end while -- end the page if not endPage() then -- flag printer error printErr = True end if -- return the unprinted portion return doc[z .. length(doc)] end function -- do nothing return end if result = getPageSetup() if not sequence(result) then return end if -- start the document if not startDoc( jobName ) then -- error printErr = True end if -- until end of document or error while length( doc ) != 0 and not printErr do -- send document to printer; returns unprinted amount doc = printPage( doc ) end while -- end the document if not endDoc() then printErr = True end if end procedure -- print document on printer integer at, ignore sequence result, doc -- clear the error flag printErr = False -- select the printer result = getPrinter() if length( result ) = 0 then -- user cancelled return end if doc = drawText(Printer, getRichText(MyText ,-1),{5,5,140, 75}, DT_WORDBREAK, 4, 0, 0) -- set the font setFont( Printer, fontstyle, fontsize, Normal ) -- print the document printDoc( doc, "Test Document" ) -- release the printer releasePrinter() -- was there an error? if printErr then -- display an error message ignore = message_box( "Print File Error", "Error Printing File", MB_ICONHAND+MB_TASKMODAL ) end if end procedure
4. Re: Breaking text when printing
- Posted by Derek Parnell <ddparnell at bigpond.com> Aug 03, 2004
- 500 views
EU Coder wrote: > > Thank you Derek > > I tried your suggestion, but when the page prints I get a sequence of > numbers instead of the text. Okay, I've done a bit of research into this now, and its not quite as straight forward as I'd hoped for. I'll knock up a demo program and post it here later. It might take a day or two or three, as I'm busy with other things too. -- Derek Parnell Melbourne, Australia
5. Re: Breaking text when printing
- Posted by "EU Coder" <eucoder at hotmail.com> Aug 03, 2004
- 498 views
>Okay, I've done a bit of research into this now, and its not quite as >straight forward as I'd hoped for. I'll knock up a demo program and post >it here later. It might take a day or two or three, as I'm busy with other >things too. Thanks