How to print qr code

523 views
Skip to first unread message

Michael

unread,
Oct 3, 2021, 4:49:40 AM10/3/21
to Harbour Users

Hello,

Any ideas ?


Best Regards
Message has been deleted

ohaldi

unread,
Oct 3, 2021, 6:04:37 AM10/3/21
to Harbour Users
Hello,
With the help of PageScript, I could create the new Swiss QR-Bill.
SwissQR-Bill_Sample.jpg
Have a look at the Zip File.
Remarque : I'm using xHarbour!
Regards
Otto

PSTestQrCode.prg

Pete

unread,
Oct 4, 2021, 5:33:44 AM10/4/21
to Harbour Users
hbZebra & hbhpdf libraries are your friends, and more precisely,
the genius developers who created these excellent contrib libraries!

regards,
Pete

Yakano

unread,
Oct 4, 2021, 5:54:58 AM10/4/21
to Harbour Users
Hi Otto

I use PageScript and thought that PageScript had disappeared 6-7 years ago (in fact its website looks like a Micro$oft partner) and that has always worried me: the dependence on third-party software without ongoing development.

I remember that when I started with Habour, AbeeLabs released a free version that came with the instructions to incorporate it as a library (and that's what I did), although now I don't remember where I saved it or the steps I took (serious mistake). At least I have found in "\ HB32 \ extras \ ps32" the files involved and the instructions for [vszakats] in readme.txt, along with the file tpscript.prg, which I understand is the most important.

Well Otto, when I try to link your code I get the following error ... ".Hbmk / win / mingw / PSTestQrCode.o: PSTestQrCode.c :(. Data + 0x188): undefined reference to` HB_FUN_PSQRCODE '" It seems that the released version did not include this function or that it was only available for xHarbour.

But I have investigated something (googled) and I have found what seems to be the continuation of the great work of AbeeLabs, on the website "https://www.pagescript32.com/" and when downloading the full version, there is no information on "help.chm", but I find a DLL updated to 2020 and a TPSCRIPT.PRG from 2018 that does have references to the "PsQrCode" function.

Can you confirm that this is the correct way or give us some extra information to achieve this function? 

 Thanks!

ohaldi

unread,
Oct 4, 2021, 6:10:06 AM10/4/21
to Harbour Users
This is the information I received at the time from the support : sup...@pagescript32.com.
--------------------------------------------------------
Method .....: #QRCode(<n>, <n>, <c>, [<n>]) -> NIL
Description : Print a QRcode
Parameter nVersion : can be any value between 1 and 40 ( Symbolsize 21*21 modules to 177 * 177 )
                     increasing in steps of 4 modules per side.
Parameter nSize    : Size in pixels 100 * 100 by default
Parameter nModuleWidth : size in pixels of the dots in the QRCode
-----------------------------------------------------------------------------*

Please use as in  PSQRCode(10,10,'test message',1,100,100)
Regards,
Richard

Eduardo Motta

unread,
Oct 4, 2021, 7:23:08 AM10/4/21
to Harbour Users

obs: neste link tem o codigo fonte e a dll

http://www.emotta.com.br/qrcode/qrcode.rar

 #include "fivewin.ch"


Function u_Teste()
Local cStr  := "AQUI DEVE SER COLOCADO O CONTEUDO DO QRCODE"
Local cFile := "arq.bmp"
Local oDlg
Local oBmp1

QRCode(cStr,cFile)  // aqui vc chama a funcao passando como parametro o conteudo do QRCODE e o arquivo BMP que será gerado

DEFINE DIALOG oDlg FROM 0,0 TO 300,300 TITLE "Exibir QRCODE" PIXEL

@ 10,10 BITMAP oBmp1 FILE cFile OF oDlg Size 200,200 Pixel NOBORDER

ACTIVATE DIALOG oDlg CENTERED 

Return

DLL32 STATIC FUNCTION QRCode(cStr As STRING, cFile As STRING) AS LONG PASCAL FROM "FastQRCode" LIB "QRCodelib.Dll"

Clippero

unread,
Oct 4, 2021, 9:14:20 AM10/4/21
to Harbour Users
Con estas librerías:

libs=hbzebra
libs=hbhpdf
libs=libhpdf

Incluyendo:

#require "hbzebra"
#include "harupdf.ch"

Se arma el .pdf con harupdf y se pone el QR dentro del objeto pdf de la página 

Suerte !



*************************************************
* Pageobj    = Objeto pagina del oPDF
* Pdfobj     = Objeto del oPDF
* nX         = Coordenadas eje X en DPI
* nY         = Coordenas eje Y en Pdfobj:nRow
* nLineWidth = Profundidad de la linea del codigo
* cType      = Tipo de codigo
* cCode      = Texto del codigo
* prtCode    = Se imprime el cCode o no
* nletra     = Tamanio del font
* nFlags     = Ni La Mas Puta Idea
********************                                && GENERA CODIGOS DE BARRA PARA EL PDF
Function DrawBarcode( Pageobj, Pdfobj, nX, nY, nLineWidth, cType, cCode, prtCode, nletra, nFlags )

LOCAL hZebra, nLineHeight, cTxt

IF prtCode=NIL
   prtCode:=.F.
ENDIF

IF nletra=NIL
   nletra:=09
ENDIF

IF nY=NIL
   nY:=0
ENDIF

IF nX=NIL
   nX:=05
ENDIF

nY := nY * nletra * Pdfobj:nLineHeight       && CONVIERTE DE nY=Pdfobj:nRow a nY=DPI

nY := HPDF_Page_GetHeight( Pageobj ) - nY

DO CASE
   CASE cType="EAN13"
        hZebra := hb_zebra_create_ean13( cCode, nFlags )
   CASE cType="EAN8"
        hZebra := hb_zebra_create_ean8( cCode, nFlags )
   CASE cType="UPCA"
        hZebra := hb_zebra_create_upca( cCode, nFlags )
   CASE cType="UPCE"
        hZebra := hb_zebra_create_upce( cCode, nFlags )
   CASE cType="CODE39"
        hZebra := hb_zebra_create_code39( cCode, nFlags )
   CASE cType="ITF"
        hZebra := hb_zebra_create_itf( cCode, nFlags )
   CASE cType="MSI"
        hZebra := hb_zebra_create_msi( cCode, nFlags )
   CASE cType="CODABAR"
        hZebra := hb_zebra_create_codabar( cCode, nFlags )
   CASE cType="CODE93"
        hZebra := hb_zebra_create_code93( cCode, nFlags )
   CASE cType="CODE11"
        hZebra := hb_zebra_create_code11( cCode, nFlags )
   CASE cType="CODE128"
        hZebra := hb_zebra_create_code128( cCode, nFlags )
   CASE cType="PDF417"
        hZebra := hb_zebra_create_pdf417( cCode, nFlags )
        nLineHeight := nLineWidth * 3
   CASE cType="DATAMATRIX"
        hZebra := hb_zebra_create_datamatrix( cCode, nFlags )
        nLineHeight := nLineWidth
   CASE cType="QRCODE"
        hZebra := hb_zebra_create_qrcode( cCode, nFlags )
        nLineHeight := nLineWidth
ENDCASE

IF hZebra != NIL
   IF hb_zebra_geterror( hZebra ) == 0
      IF Empty( nLineHeight )
         nLineHeight := 16
      ENDIF

      cTxt := hb_zebra_getcode( hZebra )

      IF prtCode
         oPDF:DrawText( Pdfobj:nRow+=3, 01, cCode,,nletra,"Courier" )
      ENDIF

      hb_zebra_draw_hpdf( hZebra, Pageobj, nX, nY, nLineWidth, -nLineHeight )

     ELSE
      ALERT("Tipo= "+cType+";Codigo= "+cCode+";Error= "+STR(hb_zebra_geterror( hZebra )) )
   ENDIF
   hb_zebra_destroy( hZebra )
  ELSE
   ALERT("TIPO DE CODIGO DE BARRAS INCORRECTO; ;"+cType)
ENDIF

RETURN ""

********************************
* hZebra     = Codigo de barras
* PageObj    = Objeto pagina
* nX         = Coordenadas eje X
* nY         = Coordenadas eje Y
* nLineWidth = Ancho del codigo
* nLineHeight= Alto del codigo
***************
STATIC FUNCTION hb_zebra_draw_hpdf( hZebra, Pageobj, ... )

IF hb_zebra_geterror( hZebra ) != 0
  RETURN HB_ZEBRA_ERROR_INVALIDZEBRA
ENDIF

hb_zebra_draw( hZebra, {| x, y, w, h | HPDF_Page_Rectangle( Pageobj, x, y, w, h ) }, ... )

HPDF_Page_Fill( Pageobj )

RETURN 0

Michael

unread,
Oct 10, 2021, 8:08:30 AM10/10/21
to Harbour Users
Hello again

Thanks for all answer !

How to read this code from scanner in Harbour Aplication ?

Have a nice sunday !
Best Regards
Reply all
Reply to author
Forward
0 new messages