Re: Breaking text when printing
- Posted by "EU Coder" <eucoder at hotmail.com> Aug 02, 2004
- 501 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