FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour CODIGO DE BARRAS. ERROR CON FILLRECT()
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Mon May 13, 2024 11:55 AM
Mira se no 茅s esto:
Code (fw): Select all Collapse
\source\function\IMGTXTIO.PRG
https://www.forums.fivetechsupport.com/viewtopic.php?f=3&t=39585#p263522

Regards, saludos.
Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Tue May 14, 2024 06:11 AM
pedroluis wrote:Hola amigos !

Como puedo solucionar la impresi贸n de un c贸digo de barras
que saqu茅 de barlib.zip de libre distribuci贸n,
que tiene el programa go_code.prg y que me da error al
querer imprimir al usar la funci贸n FILLRECT().
Gracias, como siempre !

Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20221118)
FiveWin version: FWH 23.07
C compiler version: Borland/Embarcadero C++ 7.4 (32-bit)
Windows 10 64 Bits, version: 6.2, Build 9200

Error description: Warning BASE/1004 Message not found: FWPDF:FILLRECT

Stack Calls
===========
Called from: source\rtl\tobject.prg => FWPDF:ERROR( 0 )
Called from: source\rtl\tobject.prg => FWPDF:MSGNOTFOUND( 0 )
Called from: source\rtl\tobject.prg => FWPDF:FILLRECT( 0 )
Called from: go_code.prg => GO_CODE( 38 )
Called from: barlib.prg => CODE128( 34 )
Called from: barlib.prg => C_CODE128( 39 )
FWH uses FWPDF class to generate PDF using HaruPDF.
As of now, this class does not support the method FillRect().

So, while using this 3rd party lib "barlib.prg", we need to generate PDF without using HaruPDF.
Please do
Code (fw): Select all Collapse
TPrinter():lUseHaruPDF := .F.
PRINT oPrn FILE cPdf
After seeing your posting, we are considering making some additions to FWPDF class . This may take a few days and we will share the new fwpdf.prg once it is ready.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Tue May 14, 2024 07:05 AM
But most importantly, we DO NOT NEED any 3rd party library for generating, display and printing any barcodes or QRCodes.

FWH is natively capable of generating and printing not only CODE128 barcodes but many other types of barcodes and qr-codes, with or without HaruPDF.

Please try this small example:
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST FWZEBRA
REQUEST FWHARU

function Main()

聽 聽local cName, cCity, cCountry, cItem
聽 聽local oPrn, oFont

聽 聽cName 聽 聽:= "Antonio Linares"
聽 聽cCity 聽 聽:= "Marbella"
聽 聽cCountry := "Spain"
聽 聽cItem 聽 聽:= "123456789012"

聽 聽TPrinter():lUseHaruPDF := .t.

聽 聽PRINT oPrn PREVIEW FILE "barcode.pdf"

聽 聽DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14 OF oPrn

聽 聽PAGE

聽 聽@ 1.00, 1 PRINT TO oPrn TEXT cName 聽 聽SIZE 4, 0.3 INCHES FONT oFont
聽 聽@ 1.30, 1 PRINT TO oPrn TEXT cCity 聽 聽SIZE 4, 0.3 INCHES FONT oFont
聽 聽@ 1.60, 1 PRINT TO oPrn TEXT cCountry SIZE 4, 0.3 INCHES FONT oFont
聽 聽@ 1.90, 1 PRINT TO oPrn TEXT cItem 聽 聽SIZE 4, 0.3 INCHES FONT oFont

聽 聽@ 1.00,5.00 PRINT TO oPrn TEXT "Address :" + CRLF + cName + CRLF + cCity + CRLF + cCountry + CRLF + cItem ;
聽 聽 聽 AS BARCODE TYPE "QR-CODE" SIZE 2,2 INCHES

聽 聽@ 3.0, 1 PRINT TO oPrn TEXT cName + " : CODE128" SIZE 4.0, 0.3 INCHES FONT oFont
聽 聽@ 3.5, 1 PRINT TO oPrn TEXT cName AS BARCODE TYPE "CODE128" SIZE 4,1 INCHES

聽 聽@ 5.5, 1 PRINT TO oPrn TEXT cItem + " : EAN13" SIZE 4.0, 0.3 INCHES FONT oFont
聽 聽@ 6.0, 1 PRINT TO oPrn TEXT cItem AS BARCODE TYPE "EAN13" SIZE 4,1 INCHES

聽 聽ENDPAGE

聽 聽ENDPRINT

聽 聽RELEASE FONT oFont

return nil
Please build this sample in the samples folder using buildh.bat or buildx.bat.

This is the screen-shot of PDF file generated with HaruPDF:



Please re-consider.
Do you really need a 3rd party lib?
Why can you not use FWH native capability to generate Bar Codes?
Regards



G. N. Rao.

Hyderabad, India
Posts: 117
Joined: Sun Oct 08, 2017 12:51 PM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Tue May 14, 2024 01:43 PM

Muchas gracias Sr. Rao, funciona perfecto !

Como dice usted, no hace falta usar una librer铆a externa.

S贸lo unos problemitas:

1) En mi programa tengo 17 fonts distintos, y cuando imprime el c贸digo de barras realmente no se cu谩l toma y no se como definirle uno determinado.

2) En el SIZE <nWidth>, si pongo un valor menor que 4, queda igual. No se achica. El BARSIZE <nSize> no funciona. Me da error de compilaci贸n.

Pero a pesar de todo, con la respuesta que amablemente me pas贸, se pudo solucionar el problema.

Muchisimas gracias !

Pedro L. Lavallen

San Luis (Capital), Argentina
Posts: 117
Joined: Sun Oct 08, 2017 12:51 PM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Tue May 14, 2024 03:08 PM

Sr.Rao

No puedo ajustar el ancho del c贸digo de barras

Necesito que tenga 4 cms. de ancho y sale de 4.7 cms.

@ 25.55+x3,01.00 PRINT TO oPrn TEXT mcodbar1 AS BARCODE TYPE "CODE128" SIZE 4,0.8 CM

La altura de 0.8 cms sale bi茅n.

Gracias !

Pedro L. Lavallen

San Luis (Capital), Argentina
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Tue May 14, 2024 03:20 PM
Pedro, con el ejemplo de Mr. Rao, puedes darle el ancho y largo al codigo de barra o QR en el mismo SIZE
Te dejo el ejemplo
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST FWZEBRA
REQUEST FWHARU

function Main()

聽 聽local cName, cCity, cCountry, cItem
聽 聽local oPrn, oFont

聽 聽cName 聽 聽:= "Antonio Linares"
聽 聽cCity 聽 聽:= "Marbella"
聽 聽cCountry := "Spain"
聽 聽cItem 聽 聽:= "123456789012"

聽 聽TPrinter():lUseHaruPDF := .t.

聽 聽PRINT oPrn PREVIEW FILE "barcode.pdf"

聽 聽DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14 OF oPrn

聽 聽PAGE

聽 聽@ 1.00, 1 PRINT TO oPrn TEXT cName 聽 聽SIZE 4, 0.3 INCHES FONT oFont
聽 聽@ 1.30, 1 PRINT TO oPrn TEXT cCity 聽 聽SIZE 4, 0.3 INCHES FONT oFont
聽 聽@ 1.60, 1 PRINT TO oPrn TEXT cCountry SIZE 4, 0.3 INCHES FONT oFont
聽 聽@ 1.90, 1 PRINT TO oPrn TEXT cItem 聽 聽SIZE 4, 0.3 INCHES FONT oFont

聽 聽@ 1.00,5.00 PRINT TO oPrn TEXT "Address :" + CRLF + cName + CRLF + cCity + CRLF + cCountry + CRLF + cItem ;
聽 聽 聽 AS BARCODE TYPE "QR-CODE" SIZE 2,2 INCHES
聽 聽@ 1.00,7.50 PRINT TO oPrn TEXT "Address :" + CRLF + cName + CRLF + cCity + CRLF + cCountry + CRLF + cItem ;
聽 聽 聽 AS BARCODE TYPE "QR-CODE" SIZE 0.5,0.5 INCHES 聽 // Mas chico

聽 聽@ 3.0, 1 PRINT TO oPrn TEXT cName + " : CODE128" SIZE 4.0, 0.3 INCHES FONT oFont
聽 聽@ 3.5, 1 PRINT TO oPrn TEXT cName AS BARCODE TYPE "CODE128" SIZE 4,1 INCHES
聽 聽@ 3.5, 5.2 PRINT TO oPrn TEXT cName AS BARCODE TYPE "CODE128" SIZE 1.2,0.3 INCHES //Mas chico

聽 聽@ 5.5, 1 PRINT TO oPrn TEXT cItem + " : EAN13" SIZE 4.0, 0.3 INCHES FONT oFont
聽 聽@ 6.0, 1 PRINT TO oPrn TEXT cItem AS BARCODE TYPE "EAN13" SIZE 4,1 INCHES
聽 聽@ 6.0, 5.2 PRINT TO oPrn TEXT cItem AS BARCODE TYPE "EAN13" SIZE 0.5,0.2 INCHES //Mas chico

聽 聽ENDPAGE

聽 聽ENDPRINT

聽 聽RELEASE FONT oFont

return nil
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Tue May 14, 2024 05:44 PM
1) En mi programa tengo 17 fonts distintos, y cuando imprime el c贸digo de barras realmente no se cu谩l toma y no se como definirle uno determinado.
Barcode does not use any font. Nothing to do with fonts.

2) En el SIZE <nWidth>, si pongo un valor menor que 4, queda igual. No se achica. El BARSIZE <nSize> no funciona. Me da error de compilaci贸n.
We need to provide both width and height in the SIZE clause
Code (fw): Select all Collapse
.. SIZE 聽nWidth, nHeight UNITS INCHES/CM/MM
Please give me a sample text and the maximum width and height ( in CM ) you want.
In any case, text of a given length requires a minimum width because each character requires some minimum number of pixels.
Regards



G. N. Rao.

Hyderabad, India
Posts: 117
Joined: Sun Oct 08, 2017 12:51 PM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Tue May 14, 2024 08:12 PM

Este c贸digo de barras, tendr铆a que tener 4 CM 100003222186321900 (18 d铆gitos)

Este otro c贸digo de barras tendr铆a que tener 8.5 CM 30634973938A00030000322274188595079486 (38 d铆gitos)

Pedro L. Lavallen

San Luis (Capital), Argentina
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Tue May 14, 2024 09:14 PM
Asi podrias definirlas
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST FWZEBRA
REQUEST FWHARU

function Main()

聽 聽local cName, cCity, cCountry, cItem, cItem2
聽 聽local oPrn, oFont, oFont1

聽 聽cName 聽 聽:= "Antonio Linares"
聽 聽cCity 聽 聽:= "Marbella"
聽 聽cCountry := "Spain"
聽 聽cItem 聽 聽:= "100003222186321900"
聽 聽cItem2 聽 := "30634973938A00030000322274188595079486"

聽 聽TPrinter():lUseHaruPDF := .t.

聽 聽PRINT oPrn PREVIEW FILE "barcode.pdf"

聽 聽DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14 OF oPrn
聽 聽DEFINE FONT oFont1 NAME "TAHOMA" SIZE 0,-07 OF oPrn

聽 聽PAGE

聽 聽@ 1.00, 1 PRINT TO oPrn TEXT cName 聽 聽SIZE 4, 0.3 CM FONT oFont
聽 聽@ 2.00, 1 PRINT TO oPrn TEXT cCity 聽 聽SIZE 4, 0.3 CM FONT oFont
聽 聽@ 3.00, 1 PRINT TO oPrn TEXT cCountry SIZE 4, 0.3 CM FONT oFont
聽 聽@ 4.00, 1 PRINT TO oPrn TEXT cItem 聽 聽SIZE 4, 0.3 CM FONT oFont

聽 聽@ 5.0, 1 PRINT TO oPrn TEXT cItem 聽 SIZE 7.5, 3 CM FONT oFont1
聽 聽@ 5.0, 9 PRINT TO oPrn TEXT cItem AS BARCODE TYPE "CODE128" SIZE 4,1 CM


聽 聽@ 7.5, 1 PRINT TO oPrn TEXT cItem2 SIZE 7.5, 3 CM FONT oFont1
聽 聽@ 7.5, 9 PRINT TO oPrn TEXT cItem2 AS BARCODE TYPE "CODE128" SIZE 8.5,1 CM
聽 聽

聽 聽ENDPAGE

聽 聽ENDPRINT

聽 聽RELEASE FONT oFont

return nil
Posts: 117
Joined: Sun Oct 08, 2017 12:51 PM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Wed May 15, 2024 01:04 AM

Hola amigo !

El tema es que el primero quiero que me quede de un tama帽o de 4 cmts. y el segundo de 8,5 una vez impresos,

y eso es lo que no logro.

Pedro L. Lavallen

San Luis (Capital), Argentina
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Wed May 15, 2024 02:07 AM
pedroluis wrote:Hola amigo !

El tema es que el primero quiero que me quede de un tama帽o de 4 cmts. y el segundo de 8,5 una vez impresos,
y eso es lo que no logro.
Una idea loca, prueba con (4.00) , (0.8 )
"Los errores en programaci贸n, siempre est谩n entre la silla y el teclado..."



Fwh 19.06 32 bits + Harbour 3.2 + Borland 7.4 + MariaDB + TDolphin



Carora, Estado Lara, Venezuela.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Wed May 15, 2024 09:26 AM
pedroluis wrote:Hola amigo !

El tema es que el primero quiero que me quede de un tama帽o de 4 cmts. y el segundo de 8,5 una vez impresos,
y eso es lo que no logro.
Is this a legal requirement? Don't we have any choice to increase the size by an extra of 1/2 cm?
Regards



G. N. Rao.

Hyderabad, India
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Wed May 15, 2024 12:43 PM

Pedro, tienes raz贸n

Aunque le indicamos 4cm el ancho del codigo de barra es 4.5 cm aprox y el de 8.5 es casi 9.5 cm

No habia hecho la prueba de medirlos

Tambien prob茅 con mm y el resultado es el mismo.

Tal vez Mr. Rao nos pueda explicar si hay alguna solucion

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Wed May 15, 2024 12:57 PM
Barcode requires a minimum width in pixels depending on the length of the text.
Harupdf uses 72 pixels per inch and so the barcode can not fit the size you require.
So let us not use Harupdf. FWH can still produce PDF files without using Harupdf

Please try this:
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST FWZEBRA
REQUEST FWHARU

//----------------------------------------------------------------------------//

function Main()

聽 聽local cItem1 聽 := "100003222186321900"
聽 聽local cItem2 聽 := "30634973938A00030000322274188595079486"
聽 聽local oPrn, oPen, oFont

聽 聽TPrinter():lUseHaruPDF := .F. 聽 // Not using HaruPDF

聽 聽PRINT oPrn PREVIEW FILE "barcode.pdf"

聽 聽DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14 OF oPrn
聽 聽DEFINE PEN oPen WIDTH 1 COLOR CLR_HRED OF oPrn

聽 聽PAGE

聽 聽@ 聽3, 2 PRINT TO oPrn TEXT cItem1 SIZE 10,1 CM FONT oFont
聽 聽oPrn:Lines( { { 4, 2 }, { 4, 6 }, { 4.4, 6 } }, oPen, "CM" )
聽 聽@ 4.5, 2 PRINT TO oPrn TEXT cItem1 AS BARCODE TYPE "CODE128" SIZE 4,1 CM

聽 聽@ 10, 2 PRINT TO oPrn TEXT cItem2 SIZE 20,1 CM FONT oFont
聽 聽oPrn:Lines( { { 11, 2 }, { 11, 10.5 }, { 11.4, 10.5 } }, oPen, "CM" )
聽 聽@ 11.5, 2 PRINT TO oPrn TEXT cItem2 AS BARCODE TYPE "CODE128" SIZE 8.5,1 CM

聽 聽ENDPAGE

聽 聽ENDPRINT

聽 聽RELEASE FONT oFont

return nil
Now the barcodes fit within 4.0 cm and 8.5 cm. I checked by printing on paper and measuring it.
Regards



G. N. Rao.

Hyderabad, India
Posts: 117
Joined: Sun Oct 08, 2017 12:51 PM
Re: CODIGO DE BARRAS. ERROR CON FILLRECT()
Posted: Wed May 15, 2024 01:54 PM

Ok Sr. Rao.

Entendido !!!

Muchas gracias y disculpe las molestias.

Pedro L. Lavallen

San Luis (Capital), Argentina