Can’t get DrawText to print on proper row.

Just starting out? Need help? Post your questions and find answers here.
User avatar
Columbo
Enthusiast
Enthusiast
Posts: 303
Joined: Wed Sep 10, 2014 7:17 am
Location: Ontario Canada
Contact:

Can’t get DrawText to print on proper row.

Post 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?
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
User avatar
mk-soft
Always Here
Always Here
Posts: 6202
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Can’t get DrawText to print on proper row.

Post by mk-soft »

See PB Help PrinterPageWidth und Height.
Perhaps your new printer have an other DPI
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Columbo
Enthusiast
Enthusiast
Posts: 303
Joined: Wed Sep 10, 2014 7:17 am
Location: Ontario Canada
Contact:

Re: Can’t get DrawText to print on proper row.

Post 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
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Can’t get DrawText to print on proper row.

Post 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.
User avatar
Columbo
Enthusiast
Enthusiast
Posts: 303
Joined: Wed Sep 10, 2014 7:17 am
Location: Ontario Canada
Contact:

Re: Can’t get DrawText to print on proper row.

Post by Columbo »

Thanks infratec. I'll give that a try.
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
User avatar
Columbo
Enthusiast
Enthusiast
Posts: 303
Joined: Wed Sep 10, 2014 7:17 am
Location: Ontario Canada
Contact:

Re: Can’t get DrawText to print on proper row.

Post by Columbo »

I tried the StartVectorDrawing() but no difference? Can't figure out why a simple change of printers creates such a problem?
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Can’t get DrawText to print on proper row.

Post 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
Post Reply