Recent

Author Topic: Printer4Lazarus Printing question.  (Read 1166 times)

asmx

  • New Member
  • *
  • Posts: 14
Printer4Lazarus Printing question.
« on: January 21, 2024, 09:33:38 am »
Very strange, Printer4Lazarus will reverse left and right when printing content containing numbers and /.

Code: Pascal  [Select][+][-]
  1. var TextStyle: TTextStyle;
  2. ...
  3. TextStyle.Layout := tlTop;
  4. TextStyle.SingleLine := False;
  5. TextStyle.Clipping := False;
  6. TextStyle.EndEllipsis := False;
  7. TextStyle.Wordbreak := True;
  8. TextStyle.SystemFont := False;
  9. TextStyle.Alignment := taLeftJustify;
  10.  
  11. Printer.Canvas.TextRect(TRect.Create(0, 0, Printer.PaperSize.Width, Printer.PaperSize.Height), 0, 0, '5.6/X', TextStyle);
  12.  

wp

  • Hero Member
  • *****
  • Posts: 12299
Re: Printer4Lazarus Printing question.
« Reply #1 on: January 21, 2024, 10:21:15 am »
If the code show is all that you do with the TextStyle variable then you did not initialize it properly. There is also the field RightToLeft which you did not fill, and thus might have the value 'true' which exactly causes this effect.

The best way to initialize TextStyle is first to assign to it the currently used values of the Canvas.TextStyle, and then to modifiy the fields that you want to:
Code: Pascal  [Select][+][-]
  1. var
  2.   TextStyle: TTextStyle;
  3. ...
  4.   TextStyle := Printer.Canvas.TextStyle;
  5.   TextStyle.SingleLine := false;
  6.   TextStyle.WordBreak := true;
  7.   Printer.Canvas.TextRect(TRect.Create(0, 0, Printer.PaperSize.Width, Printer.PaperSize.Height), 0, 0, '5.6/X', TextStyle);
« Last Edit: January 21, 2024, 12:51:54 pm by wp »

asmx

  • New Member
  • *
  • Posts: 14
Re: Printer4Lazarus Printing question.
« Reply #2 on: January 21, 2024, 12:48:22 pm »
@wp

Thank you very much! this is indeed the problem.

 

TinyPortal © 2005-2018