Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi - Text is printed out on black background

I print out text on the printer canvas using Printer.Canvas.TextOut().

I have several printer jobs defined - some for graphics and some for plain text. This has worked fine until now. Now I have a problem that plain text prints out on a black background.

This happens only if I do a graphical print before a text print (it doesn't matter whether the same printer is used or not).

I have no idea what is causing this problem. I don't set a black background anywhere. So I hope that you can help.

The problem appears with PCL & Postscript.

In the print preview of my PCL-printer, everything looks fine. However, the final print on paper is black on black again.

Could there be a transparency flag causing this problem?


Edit: It seems the transparency was causing the problem. If I use:

SetBkMode( Printer.Canvas.Handle, TRANSPARENT );

before printing the plain text, everything works fine now. It seems I messed up something somewhere.

like image 811
Jens Avatar asked Nov 23 '25 05:11

Jens


1 Answers

Setting the BkMode to transparent solved the problem - but it was only a workaround.

The reason for the problem was that in the graphic print, Printer.Canvas.Brush.Color was being set to clBlack when drawing solid circles. And this value was not being reset correctly.

like image 78
Jens Avatar answered Nov 24 '25 20:11

Jens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!