I have been unable to print properly the text content of the Editor Gadget. I wanted a simple solution that was cross platform and didn't involve third party libraries. The only previous printing I have done used the klutzy shellexecute method, I wanted something better. I tried many examples without successes and I even had the AI's try. Eventually they suggested I ask in the forums. The best I have done was with this code from srods post here, https://www.purebasic.fr/english/viewto ... 96#p548696 where he was responding to Colombo, who was suffering Printer Hell himself. This almost works, it prints 4 copies of the text, gradually shifting down and across the page then some printer job comments. I have fiddled with it endlessly and I'm going backwards. Here's the code.
Code: Select all
Procedure PrintTextFile()
Protected text.s
Protected line.s
Protected printer.i
Protected output.i
Protected lineNum.i
Protected lineCount.i
Protected vPos.i
Protected textHeight.i
Protected pageHeight.i
lineCount = CountGadgetItems(0)
lineNum = 0
text.s = ""
text.s = GetGadgetText(0)
If PrintRequester()
If StartPrinting(text)
LoadFont(0, "Arial", 65)
LoadFont(1, "Arial", 65)
If StartDrawing(PrinterOutput())
BackColor(RGB(255, 255, 255)) ; Uses white as back color, usuful when printing on a white sheet
FrontColor(RGB(0, 0, 0)) ; Use black for standard text color
DrawingFont(FontID(0))
textHeight = TextHeight("A")
pageHeight = OutputHeight()
vPos = 0
For lineNum = 0 To lineCount-1
If vPos + textHeight >= pageHeight
vPos = 0
NewPrinterPage()
EndIf
line.s = GetGadgetItemText(0, lineNum)
DrawText(50, vPos, line)
vPos + TextHeight
Next
StopDrawing()
EndIf
StopPrinting()
EndIf