-1

I want to print a QR in my thermal printer. I use the following command

lpr -P POS58 qr.png

As you can see my QR is a PNG image. It prints it totally fine except for the fact that before the QR the printer leaves a lot of blank paper.

How could I fix this?

Kuznov
  • 11
  • 1
  • Please check the control code of your printer, convert the image file data to a format suitable for it, and then send it with the lpr command. – kunif Dec 14 '21 at 23:34
  • It's controlled via the ESC/POS set. Isn't png already suitable? I mean, it does get printed fine, the problem is the space above. I tried now using this png2escpos library [Link](https://github.com/twg/png2escpos) but now it prints it waay bigger so only the left side fits in the paper. – Kuznov Dec 15 '21 at 10:39
  • Thermal receipt printers do not support any image file format as it is, not just png. They must be converted to the format specified in the ESC/POS control command and sent. And thermal receipt printers only support up to a certain number of dots in a certain width associated with paper width. The image data to be printed needs to be enlarged/reduced according to the number of dots. If the conversion library does not have that function, you need to adjust the image data to a size suitable for the paper before calling it. – kunif Dec 15 '21 at 11:01

1 Answers1

0

The solution I found is using again the png2escpos library Link previously reducing the size of the image to ~250px wide so it fits in the paper size (I had to try a couple of times before getting it right). You can save the binary data in a file so you can print it directly later

./png2escpos my_qr.png > my_qr.bin

Kuznov
  • 11
  • 1