Recent

Author Topic: [Solved] QR codes & Receipt printer  (Read 335 times)

Petrus Vorster

  • Full Member
  • ***
  • Posts: 183
[Solved] QR codes & Receipt printer
« on: December 02, 2025, 12:16:21 pm »
Hi All

I can use the Qr code component to print individual labels on a label printer or receipt printers.
What I now need to do it print a whole bunch of different QR codes on a receipt.

Its just a simple loop from a listbox but I have always used a command to set up a RECT to allow the placement of the barcode, bit this command seems to cause problems:

Code: Pascal  [Select][+][-]
  1.  Barcodeqr1.PaintOnCanvas(printer.Canvas,myrect);  
The command works perfect if you print one receipt or one label , then do the printer.enddoc, then print a new receipt/label.

To do that in a loop i tried:
Code: Pascal  [Select][+][-]
  1.  l:= 20;
  2.   t:= 50;
  3.     for i := 0 to ListBox1.Items.Count - 1 do
  4.     begin
  5.   w:=barcodeqr1.Width;
  6.   h:=barcodeQR1.Height;
  7.   myrect:=rect(l,t,w,h);
  8.     Printer.BeginDoc;
  9.     barcodeqr1.Text:=listbox1.Items[i];
  10.     barcodeqr1.Scale:=5;
  11.     Barcodeqr1.PaintOnCanvas(printer.Canvas,myrect);
  12.     inc(t,100);
  13.     end;
  14.  
  15.  printer.EndDoc;                

That causes an error of 'PRITER IS PRINTING' but it doesnt print.
It would seem that command cannot be put in a loop with the printer.

Anyone here perhaps knows how to correct that?

-Regards,
Peter
« Last Edit: December 03, 2025, 09:19:01 am by Petrus Vorster »

Petrus Vorster

  • Full Member
  • ***
  • Posts: 183
Re: QR codes & Receipt printer
« Reply #1 on: December 02, 2025, 12:40:38 pm »
Hmmm. Ive got my printer.begindoc inside the loop. >:(

Petrus Vorster

  • Full Member
  • ***
  • Posts: 183
Re: QR codes & Receipt printer
« Reply #2 on: December 02, 2025, 02:39:14 pm »
Now i have access violation errors...  :D

Anyone with ideas will be most welcome!

-Peter

jcmontherock

  • Sr. Member
  • ****
  • Posts: 320
Re: QR codes & Receipt printer
« Reply #3 on: December 02, 2025, 05:28:01 pm »
Windows 11 UTF8-64 - Lazarus 4.4-64 - FPC 3.2.2

Petrus Vorster

  • Full Member
  • ***
  • Posts: 183
Re: QR codes & Receipt printer
« Reply #4 on: December 03, 2025, 09:06:18 am »
HI

Thank you. I will need to study that.
I also notice the Qr.free which I did not do.

I need to change the data in the QR with every new QR code being printed on a receipt printer.
Its a list of tracking numbers I used to output with Code39 barcodes.
Then i changed to code128B with Lazreport which makes it very easy to print.
Unfortunately Lazreport Barcode items does not support QR codes.

The Qr codes can take more data, so I need to venture in that direction....

Thanks for the example.

-Peter

paweld

  • Hero Member
  • *****
  • Posts: 1515
Best regards / Pozdrawiam
paweld

 

TinyPortal © 2005-2018