Printing QR code on ticketprinters

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
serge_girard
Posts: 3420
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Printing QR code on ticketprinters

Post by serge_girard »

Anybody knows how to print (existing) QR code on Epson (or similar) ticketprinters?

Serge
There's nothing you can do that can't be done...
franco
Posts: 921
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Printing QR code on ticketprinters

Post by franco »

Hi Serge, I can send a picture ... .jpg to my ticket printer star tsp100. It is wrong size, but you could resize.
I am sure you have thought of this. Maybe can work.
All The Best,
Franco
Canada
User avatar
serge_girard
Posts: 3420
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Printing QR code on ticketprinters

Post by serge_girard »

I now use (in batch file: net use lpt1: \\pc.\EPSON) and then

Code: Select all

SET PRINTER TO LPT2
SET DEVICE  TO PRINTER
SET PRINTER ON  
? some codes
? 'my text'
// now how send JPG to ?
Serge
There's nothing you can do that can't be done...
franco
Posts: 921
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Printing QR code on ticketprinters

Post by franco »

Serg, I use this in my programs for printing pictures. I ran out of paper in my ticket printer so can not test right now.
But this works. Not sure if you can use. Just compile. I use 3.44.
I just went on internet and copied a sample qrcode then saved as png and jpg and put files in this folder..

Code: Select all

#include "hmg.ch"
#include "bostaurus.ch"
FUNCTION Main()
	LOCAL CImagep   :=   "serg.png"
	LOCAL Cimagej    :=  "serg.jpg"
   	IF ! FILE( cImagep ) .OR. ! FILE( cimagej)
     		 MsgInfo( "Image not found: " + cImage )
      		RETURN NIL
   	ENDIF
	SELECT HPDFDOC 'P.PDF' PAPERLENGTH 60 PAPERWIDTH 40
      	START HPDFDOC
      	START HPDFPAGE
	*SET HPDFDOC ENCODING TO "WinAnsiEncoding"
	@ 5, 2 HPDFPRINT 'Hello Serg' size 12
    	@ 15,1 HPDFPRINT IMAGE  cimagep  WIDTH 30 HEIGHT 30  type PNG
	@ 50, 10 HPDFPRINT 'Ping Style' size 12
	@ 60 ,1 HPDFPRINT IMAGE  cimagej   WIDTH 30 HEIGHT 30  type JPG 
	@ 95, 10 HPDFPRINT 'Jpg Style' size 12
	
	@ 125,2 HPDFPRINT 'Ping Style' SIZE 12
	@ 115,40 HPDFPRINT IMAGE  cimagep  WIDTH 20 HEIGHT 20  type PNG
	@ 150,2 HPDFPRINT 'Jpg Style' size 12
	@ 140,40 HPDFPRINT IMAGE  cimageJ  WIDTH 20 HEIGHT 20  type JPG



   	END HPDFPAGE
   	END HPDFDOC
   	EXECUTE FILE 'P.PDF'
RETURN NIL



Last edited by franco on Sun Jan 25, 2026 11:36 pm, edited 1 time in total.
All The Best,
Franco
Canada
User avatar
serge_girard
Posts: 3420
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Printing QR code on ticketprinters

Post by serge_girard »

Thanks! I will try as soon as I have my printer.
Serge
There's nothing you can do that can't be done...
franco
Posts: 921
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Printing QR code on ticketprinters

Post by franco »

Got it working. you may have to play with size. When you print you print actual size. It makes it clearer. Not sure how to program this.
I just right click in file and print. You could pick laser printer to try. I use Star tsp100 cutter printer.

Code: Select all


#include "hmg.ch"
#include "bostaurus.ch"

FUNCTION Main()
	LOCAL cPrinter := 'default' , LSUCCESS 
   	LOCAL CImagep   :=   "serg.png"
	LOCAL Cimagej    :=  "serg.jpg"
   	IF ! FILE( cImagep ) .OR. ! FILE( cimagej)
     		 MsgInfo( "Image not found: " + cImage )
      		RETURN NIL
   	ENDIF
	SELECT HPDFDOC 'P.PDF' PAPERLENGTH 60 PAPERWIDTH 40
      	START HPDFDOC
      	START HPDFPAGE
	*SET HPDFDOC ENCODING TO "WinAnsiEncoding"
	@ 5, 10 HPDFPRINT 'Hello Serg' size 16
    	@ 15,1 HPDFPRINT IMAGE  cimagep  WIDTH 30 HEIGHT 30  type PNG
	@ 50, 10 HPDFPRINT 'Ping Style' size 16
	@ 60 ,1 HPDFPRINT IMAGE  cimagej   WIDTH 30 HEIGHT 30  type JPG 
	@ 95, 10 HPDFPRINT 'Jpg Style' size 16


   	END HPDFPAGE
   	END HPDFDOC
   	EXECUTE FILE 'P.PDF'
RETURN NIL
All The Best,
Franco
Canada
franco
Posts: 921
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Printing QR code on ticketprinters

Post by franco »

I tested it with my Samsung phone after printing. All print outs above work. HP laser printer and star ticket printer.
All The Best,
Franco
Canada
User avatar
serge_girard
Posts: 3420
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Printing QR code on ticketprinters

Post by serge_girard »

Thanks!
There's nothing you can do that can't be done...
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Printing QR code on ticketprinters

Post by mol »

Serge, I think that your printer uses ESC/P2 codes.
You should study documentation
https://support2.epson.net/manuals/engl ... PCOM_3.HTM
In my opinion, it would be the best generate first binary file with all you want to print and then send it to printer:

Code: Select all

function FilePrint
	param cFileName, cPrintJobTitle, cPrinter
	local aDrukarki := aPrinters()

	if cPrinter = NIL
		cPrinter := WIN_PRINTERGETDEFAULT()
	endif
	if empty(cPrinter)
		cPrinter := WIN_PRINTERGETDEFAULT()
	endif
	
	if aScan( aDrukarki, cPrinter) = 0
		cPrinter := WIN_PRINTERGETDEFAULT()
	endif
		
	if type("cPrintJobTitle") <> "C"
		cPrintJobTitle := "Wydruk z programu FAKTURY " + WersjaProgramu
	endif
	WIN_PRINTFILERAW( cPrinter, cFileName, cPrintJobTitle )
	
return .f.
User avatar
serge_girard
Posts: 3420
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Printing QR code on ticketprinters

Post by serge_girard »

Thanks !

When that pirnter is my office I will continue this case,

Serge
There's nothing you can do that can't be done...
Post Reply