How to add 2d barcode to fastreport or fwh/harbour?

How to add 2d barcode to fastreport or fwh/harbour?

Postby ShumingWang » Tue Oct 08, 2024 12:50 am

I searched 2 schemes about add 2d barcode to fastreport
1. add the files into app.exe folder and input into fastreport , then you can direct designt it as a text,a imgge etc.
http://www.pudn.com/Download/item/id/2228698.html
https://download.csdn.net/download/july ... t=FastRepo

FastReport_2D_Codebar\dorado-qrcode-0.2.4-BETA.jar (47812, 2013-05-04)
FastReport_2D_Codebar\dorado-qrcode-sample-0.2.4.war (11143719, 2013-05-04)
FastReport_2D_Codebar\FastReport_2D_Codebar\frx2DBarcode.pas (2819, 2012-11-25)
FastReport_2D_Codebar\FastReport_2D_Codebar\frx2DBarcodeRTTI.pas (1167, 2012-11-25)
FastReport_2D_Codebar\FastReport_2D_Codebar\PtImageRW.dll (684032, 2007-08-20)
FastReport_2D_Codebar\FastReport_2D_Codebar\PtQREncode.dll (45056, 2007-08-20)
FastReport_2D_Codebar\FastReport_2D_Codebar\uQRCode.pas (5837, 2012-07-21)
FastReport_2D_Codebar\zxing-javase2.0.jar (31946, 2013-05-04)
FastReport_2D_Codebar\zxing2.0.jar (430433, 2013-05-04)
FastReport_2D_Codebar\FastReport_2D_Codebar (0, 2013-05-04)
FastReport_2D_Codebar (0, 2013-05-04)

But, I can't find the way how to input fastreport /frh/Harbour/Fwh .

2. use 3 party zinit.dll to get a bitmapn file the call it by fastreport,but the Delphi codes
https://www.cnblogs.com/huixch/p/695657 ... m=referral

Tanks a lots!
Shuming wang
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: How to add 2d barcode to fastreport or fwh/harbour?

Postby ShumingWang » Tue Oct 15, 2024 1:45 am

1.
FUNCTION img2dbarcode()
local h2d
private hlib
hLib = LOADLIBRARY( "zint.dll" )

h2d:=ZBarcode_Create()
//// h2d should has datas: symbology,height,width,bitmap,...
?h2d:symbology
// error: method symbology does not exsist

ZBarcode_Encode_and_buffer(h2d,"abc45",5,0)
//error: will hangup

ZBarcode_print(h2d)


ZBarcode_Delete(h2d)

FREELIBRARY( hLib )
return



dll32 function ZBarcode_Create() as LONG pascal FROM "ZBarcode_Create" lib hlib

dll32 function ZBarcode_Encode_and_Buffer(symbol as LONG ,;
source as LPSTR,length as LONG,rotate_angle as LONG) as LONG pascal FROM "ZBarcode_Encode_and_Buffer" lib hlib
// int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol,
const unsigned char *source, int length, int rotate_angle);

dll32 function ZBarcode_print(my_symbol as LONG,rotate_angle as LONG) as LONG pascal lib hlib
// int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle);

dll32 function ZBarcode_Delete(my_symbol as LONG) as LPSTR pascal FROM "ZBarcode_Delete" lib hlib

//-------------------
// import zint.dll --> zint.lib

2.

#include <zint.h>
int load2dc(int argc, char **argv)
{
struct zint_symbol *my_symbol;
my_symbol = ZBarcode_Create();
ZBarcode_Encode_and_Print(my_symbol, argv[1], 0, 0);
//here create out file 2d barcode "out.png"

ZBarcode_Delete(my_symbol);
return 0;
}
HB_FUNC ( LOAD2D)
{
load2dc(hb_parni( 1 ),hb_parc( 2 ));
}

// app.prg
loadh2d(,"12345")

//.....
// Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
//Error: Unresolved external '_ZBarcode_Create' referenced from D:\MY.LIB|my
//Error: Unresolved external '_ZBarcode_Encode_and_Print' referenced from D:\MY.LIB|my
//Error: Unresolved external '_ZBarcode_Delete' referenced from D:\MY.LIB|my


Thanks !
Shuming Wang
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: How to add 2d barcode to fastreport or fwh/harbour?

Postby ShumingWang » Fri Nov 01, 2024 2:24 am

1. Download zint.exe from https://sourceforge.net/projects/zint/files/zint/

WaitRun("zint.exe -d "+csourcestr+" -b 58 -o "+cdir) encode csourcestr:"abcd12345" to directory cdir+"\out.bmp", 58 is 2 demention coderbar brcode .

2.
implib -ae zint.lib zint.dll

#include <zint.h>
int load2dc(char *argv)
{
struct zint_symbol *my_symbol;
my_symbol = ZBarcode_Create();
ZBarcode_Encode_and_Print(my_symbol, argv, 0, 0);
//here only create output file 2d barcode "out.gif"

ZBarcode_Delete(my_symbol);
return 0;
}
HB_FUNC ( LOAD2D)
{
load2dc(hb_parc( 1 ));
}

// app.prg
load2d("abcd12345")
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: How to add 2d barcode to fastreport or fwh/harbour?

Postby albeiroval » Mon Nov 04, 2024 7:43 pm

Hi, Shuming wang.

How do I use this code in fastreport?
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 379
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: How to add 2d barcode to fastreport or fwh/harbour?

Postby ShumingWang » Tue Nov 05, 2024 3:11 am

1.1 Download zint.exe from https://sourceforge.net/projects/zint/files/zint/
New version is 2.13
1.2
fastreport--page: image type cell -- Code page:

procedure Picture12OnBeforePrint(Sender: TfrxComponent);
begin
callhbfunc('fr3img3',[trim(<masterdata."model">)+',sub']) ;
LoadImageFromHbVar(Picture1,'fr3img');
end;

// "model" cstr ,'sub': directory where out.bmp lays,picture1:your image cell name

fastreport image type cell -- event page :
onberforeprint , choose the Picture12OnBeforePrint

1.3 app prg , deinfne function fr3img3
FUNCTION fr3img3(cstr1,cdir1)
if LEN(ALLTRIM(cstr1))>0
if cdir1==nil;cdir1:=".\sub\out.bmp"; end
WaitRun("zint.exe -d "+cstr1+" -b 58 -o "+cdir1)
if FILE('.\sub\out.bmp')
fr3img:=memoread(".\sub\out.bmp")
else
fr3img:=MEMOREAD("0.jpg")
// Space image 0.jpg to avoid "0" 1 d barcode be printed.
// 58 is brcode .
end
else
fr3img:=MEMOREAD("0.jpg")
end
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
ShumingWang
 
Posts: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: How to add 2d barcode to fastreport or fwh/harbour?

Postby karinha » Tue Nov 05, 2024 10:14 am

Good morning ShopingWang. Can you make a DEMO and post it on MegaUpload? It's just that the way you're showing it, it's very confusing.

Buenos días ShopingWang. ¿Puedes hacer una DEMO y publicarla en MegaUpload? Es sólo que la forma en que lo estás mostrando es muy confusa.

Gracias, tks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: How to add 2d barcode to fastreport or fwh/harbour?

Postby albeiroval » Tue Nov 05, 2024 4:52 pm

Hi, Shuming wang.

Now it's clear to me, I will implement it. Thank you so much
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 379
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: How to add 2d barcode to fastreport or fwh/harbour?

Postby Marcelo Via Giglio » Wed Nov 06, 2024 3:40 pm

Hello,

you can use zebra lib from [x]harbour, using the TCodeBars Class, the PRG code sample

Code: Select all  Expand view  RUN

//------------------------------------------------------------------------------
FUNCTION genCodigoQR( id )
//------------------------------------------------------------------------------
   LOCAL oBmp, hDib

    oBmp := getQR(id)
    hDib = DibFromBitmap( oBmp:hBitMap )
    M -> codigoQR := DibToStr( hDib )
    GlobalFree( hDib )
    DeleteObject( oBmp )
   
RETURN M -> codigoQR

//------------------------------------------------------------------------------
FUNCTION getQR( cCode )
//------------------------------------------------------------------------------

   LOCAL oBmp

   oBmp = TBitmap():Define()
   oBmp:hBitMap := buildCode( cCode, HB_ZEBRA_FLAG_QR_LEVEL_M )

RETURN oBmp

//------------------------------------------------------------------------------
function BuildCode( cCode, nFlags )
//------------------------------------------------------------------------------
   LOCAL hDC := GetDC( GetDesktopWindow() )

   default nFlags := 0

   oCode := TCodeBars():New()   //TCodeBars Class
   oCode:Reset()

   oCode:nHeightCode = 4.5
   oCode:nWidthCode  = 4.5

   oCode:SetType( 14 )
   oCode:SetCode( cCode )
   oCode:SetFlags( nFlags )
   oCode:Build()

   ReleaseDC( GetDesktopWindow(), hDC )

RETURN oCode:hCodeBar



and from FastReport code section, for beforeprint picture event

Code: Select all  Expand view  RUN

procedure Picture2OnBeforePrint(Sender: TfrxComponent);
begin
  CallHbFunc('genCodigoQR',[<id>]);
  LoadImageFromHbVar(picture2,'codigoQR');      
end;

 
Marcelo Via Giglio
 
Posts: 1065
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 110 guests