Page 1 of 1
Can’t get DrawText to print on proper row.
Posted: Sun Oct 15, 2023 6:20 pm
by Columbo
I wrote a program a couple of years ago and it printed in the proper column and row of my form using DrawText(710, 720, pr1). Since then I got a new printer and it is not printing in the correct row on my form any more.
The code is as follows:
Code: Select all
Pr1 = "Winning team: " + ws_win
DrawingFont(FontID(0))
DrawText(710, 720, pr1)
I changed the code to:
Code: Select all
DrawingFont(FontID(0))
DrawText(710, 730, pr1)
But it still prints in the exact same row as it was before the change. Am I doing it wrong? I even thought of preceding the code with a line feed to move it down but I’m not sure how to do that in PB.
Any thoughts?
Re: Can’t get DrawText to print on proper row.
Posted: Sun Oct 15, 2023 7:01 pm
by mk-soft
See PB Help PrinterPageWidth und Height.
Perhaps your new printer have an other DPI
Re: Can’t get DrawText to print on proper row.
Posted: Sun Oct 15, 2023 7:19 pm
by Columbo
Thank you for you response mk-soft.
If the printer has a different DPI, how can I compensate for that in my program? Changing the DrawText() does seen to have any affect.
Thanks
Re: Can’t get DrawText to print on proper row.
Posted: Sun Oct 15, 2023 8:59 pm
by infratec
You have to calculate the correct coordinates.
Maybe there is an easier way (not tried yet):
Use
Code: Select all
PrinterVectorOutput(#PB_Unit_Millimeter)
Or #PB_Unit_Inch and use
Code: Select all
If StartVectorDrawing(PrinterVectorOutput(#PB_Unit_Millimeter))
MovePathCursor(40, 40)
DrawVectorText("Hello world")
StopVectorDrawing()
EndIf
Maybe it is located at the given unit values independend of the printer dpi.
Re: Can’t get DrawText to print on proper row.
Posted: Mon Oct 16, 2023 2:34 am
by Columbo
Thanks infratec. I'll give that a try.
Re: Can’t get DrawText to print on proper row.
Posted: Wed Oct 18, 2023 5:43 pm
by Columbo
I tried the StartVectorDrawing() but no difference? Can't figure out why a simple change of printers creates such a problem?
Re: Can’t get DrawText to print on proper row.
Posted: Wed Oct 18, 2023 8:15 pm
by infratec
Please try this and tell me the coordinates on the paper in cm or mm.
Code: Select all
If PrintRequester()
If StartPrinting("PureBasic Test")
If StartVectorDrawing(PrinterVectorOutput(#PB_Unit_Millimeter))
MovePathCursor(50, 50)
DrawVectorText("PureBasic Printer Test")
MovePathCursor(100, 100)
DrawVectorText("PureBasic Printer Test 2")
StopVectorDrawing()
EndIf
StopPrinting()
EndIf
EndIf
Text one should be at 5/5 cm
Text2 one should be at 10/10 cm