Ayuda con report

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
mjaviergutierrez
Posts: 146
Joined: Fri Nov 30, 2012 7:51 pm
Location: San Lorenzo, Santa Fe, Argentina

Ayuda con report

Post by mjaviergutierrez »

Hola Amigos, tengo el siguiente reporte que recorre una tabla que se llama ETIQUETAS.DBF, imprime precios para las gondolas de supermercado, tiene tres columnas definindas , en cada etiqueta imprime :
arriba el nombre del producto,
en la linea siguiente el precio en un letra mas grande,
en la linea siguiente una imagen JPG con el codigo de barras (el nombre de la imagen varia para cada registro, y el nombre está en el campo CBARRA1,CBARRA2,CBARRA3)
y en la linea siguiente un texto con el codigo de barras

en todos los registros funciona perfecto, pero cuando tiene que imprimir las imagenes , es como que no varía el valor del campo de la tabla, se queda con los del primer registro, o sea, me imprime siempre las tres primeras barras, mientras que todos los otros campos , va variando linea por linea, cambia el nombre, el precio y el código de barras , segun el registro, solo no cambia el nombre del archivo .JPG que esta en el campo CBARRA1, CBARRA2, CBARRA3 de cada registro.

paso el código :

Use ETIQUETA New Exclusive
DBGOTOP( )

DEFINE REPORT Report1

* Report Layout ***********************************************

BEGIN LAYOUT
PAPERSIZE PRINTER_PAPER_A4
ORIENTATION PRINTER_ORIENT_PORTRAIT
END LAYOUT

* Header Band *************************************************
BEGIN HEADER
BANDHEIGHT 5
END HEADER

* Detail Band *************************************************

aColumnas:={ 10 ,80 ,100 }

BEGIN DETAIL

BANDHEIGHT 40

BEGIN TEXT
EXPRESSION AllTrim( SubStr( ETIQUETA->DESCRIP1 ,1 ,50 ) )
ROW 2
COL 8
WIDTH 60
HEIGHT 10
FONTNAME 'Arial'
FONTSIZE 10
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Center
END TEXT

BEGIN TEXT
EXPRESSION AllTrim( SubStr( ETIQUETA->DESCRIP2 ,1 ,50 ) )
ROW 2
COL 75
WIDTH 60
HEIGHT 10
FONTNAME 'Arial'
FONTSIZE 10
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Center
END TEXT


BEGIN TEXT
EXPRESSION AllTrim( SubStr( ETIQUETA->DESCRIP3 ,1 ,50 ) )
ROW 2
COL 140
WIDTH 60
HEIGHT 10
FONTNAME 'Arial'
FONTSIZE 10
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Center
END TEXT


BEGIN TEXT
EXPRESSION Str( ETIQUETA->PRECIO1 ,7,2 )
ROW 5
COL 8
WIDTH 100
HEIGHT 20
FONTNAME 'Arial Black'
FONTSIZE 40
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Left
END TEXT

BEGIN TEXT
EXPRESSION Str( ETIQUETA->precio2 ,7 ,2 )
ROW 5
COL 75
WIDTH 100
HEIGHT 20
FONTNAME 'Arial Black'
FONTSIZE 40
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Left
END TEXT

BEGIN TEXT
EXPRESSION Str( ETIQUETA->precio3 ,7 ,2 )
ROW 5
COL 140
WIDTH 100
HEIGHT 20
FONTNAME 'Arial Black'
FONTSIZE 40
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Left
END TEXT


BEGIN PICTURE
VALUE ETIQUETA->CBARRA1
ROW 22
COL 24
WIDTH 30
HEIGHT 7
STRETCH .T.

END PICTURE


BEGIN PICTURE
VALUE ETIQUETA->CBARRA2
ROW 22
COL 90
WIDTH 30
HEIGHT 7
STRETCH .T.

END PICTURE

BEGIN PICTURE
VALUE ETIQUETA->CBARRA3
ROW 22
COL 156
WIDTH 30
HEIGHT 7
STRETCH .T.

END PICTURE

nRowText:=29

BEGIN TEXT
EXPRESSION PADC( ETIQUETA->CODIGO1 ,30 )
ROW nRowText
COL 9
WIDTH 60
HEIGHT 10
FONTNAME AllTrim( ETIQPARA->FONT )
FONTSIZE ETIQPARA->FONTSIZE
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Center
END TEXT // 'Matura MT Script Capitals'

BEGIN TEXT
EXPRESSION PADC( ETIQUETA->CODIGO2 ,30 )
ROW nRowText
COL 77
WIDTH 60
HEIGHT 10
FONTNAME AllTrim( ETIQPARA->FONT )
FONTSIZE ETIQPARA->FONTSIZE
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Center
END TEXT

BEGIN TEXT
EXPRESSION PADC( ETIQUETA->CODIGO3 ,30 )
ROW nRowText
COL 143
WIDTH 60
HEIGHT 10
FONTNAME AllTrim( ETIQPARA->FONT )
FONTSIZE ETIQPARA->FONTSIZE
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
FONTCOLOR { 0 , 0 , 0 }
ALIGNMENT Center
END TEXT


BEGIN LINE
FROMROW 35
FROMCOL 8
TOROW 35
TOCOL 200
PENWIDTH 0.1
PENCOLOR { 0 , 0 , 0 }
END LINE

END DETAIL

* Footer Band *************************************************
BEGIN FOOTER

BANDHEIGHT 1

END FOOTER


END REPORT

ExecuteReport('Report1',.t.,.t. )

ETIQPARA->( DBCLOSEAREA( ) )
ETIQUETA->( DBCLOSEAREA( ) )
...
User avatar
mjaviergutierrez
Posts: 146
Joined: Fri Nov 30, 2012 7:51 pm
Location: San Lorenzo, Santa Fe, Argentina

Re: Ayuda con report

Post by mjaviergutierrez »

Dejo el código en un proyecto y una imagen con el error , para ser mas claro
Attachments
ERROR_ETIQUETAQS.rar
(1.29 MiB) Downloaded 93 times
ETIQUETASERROR.jpg
ETIQUETASERROR.jpg (332.19 KiB) Viewed 1673 times
...
User avatar
AUGE_OHR
Posts: 2061
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Ayuda con report

Post by AUGE_OHR »

hi,

i have not work with "printing" yet and i wonder how you get Image

Code: Select all

ETIQUETA->CBARRA1 
how do you "store" Image in DBF :?:

all Sample that i saw use a File "HMG.JPG" but none a DBF / MEMO

---

i have use BLOB
to show it i use BLOBEXPORT() with Parameter BLOB_EXPORT_OVERWRITE
this will create a "real" Image on HDD/SSD which i can load into IMAGE

---

Code: Select all

PROCEDURE ShowPicNext()

   SKIP( + 1 )
   BLOBEXPORT( FIELDPOS( "BILDIN" ) , cOutputA, BLOB_EXPORT_OVERWRITE )
   BLOBEXPORT( FIELDPOS( "BILDOUT" ), cOutputB, BLOB_EXPORT_OVERWRITE )

   Preview.Image_In.Picture  := cOutputA
   Preview.Image_Out.Picture := cOutputB

   FERASE( cOutputA )
   FERASE( cOutputB )

RETURN
have fun
Jimmy
User avatar
mjaviergutierrez
Posts: 146
Joined: Fri Nov 30, 2012 7:51 pm
Location: San Lorenzo, Santa Fe, Argentina

Re: Ayuda con report

Post by mjaviergutierrez »

hola, gracias por responder.
la imagen fisica, por ejemplo : BARRA1.JPG está en la misma carpeta que el programa.
en el campo ETIQUETA->CBARRA1 esta el nombre de la imagen, por ejemplo BARRA1.JPG , que se traslada ala propiedad VALUE del control PICTURE.
...
franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Ayuda con report

Post by franco »

I downloaded a free barcode font off internet. It is called "free 3 of 9 extended" . and add to windows font directory.
In report I print.

Code: Select all

@ row, col print alltrim(description) font "arial" size 10
@ row, col print alltrim(str(price,10,2)) font "arial" size 40
@ row, col print alltrim(itemnumber)+"*" font "Free 3 of 9 extended" size 10       //REM: you need the * to make it work.
@ row, col print alltrim(itemnumber) font "arial" size 10
All The Best,
Franco
Canada
martingz
Posts: 395
Joined: Wed Nov 18, 2009 11:14 pm
Location: Mexico

Re: Ayuda con report

Post by martingz »

Javier uso este codigo para imprimir mas de 20,000 qrcodes y tenia ese error por que no liberaba hBitMap


hBitMap:=HMG_CreateBarCode( codigosat, "QRCODE" , 3, 3, , "", , , , , )
BT_BitmapSaveFile (hBitmap, "codigo.jpg", BT_FILEFORMAT_JPG)
BT_BitmapRelease (hBitmap)

espero que sea de tu ayuda
al ejecutar tu programa me da un error de que me falta una dbf

saludos
franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Ayuda con report

Post by franco »

Are you trying to create a code that a bar code reader can read, or is it a picture plus a barcode.
In most stores people like to use a barcode reader instead of typing the long item code.
Maybe I do not understand what you are looking for.
All The Best,
Franco
Canada
edk
Posts: 911
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Ayuda con report

Post by edk »

Hi.
Maybe I'm not writing exactly in the subject of the post, but I think it's better to print EAN, QR, Code39, etc. codes directly from the application without generating graphic files.
Some time ago, Marek (mol) shared his PrintEAN13 solution: http://hmgforum.com/viewtopic.php?p=22562#p22562
Beacause of passing Covid, I train my mind (it's not like it was before - I have a harder time doing it :x ) I adapted hb_zebra to generate barcodes directly on the printout.
Maybe it will be useful to someone.
Lots of health for everyone and take care of yourself.

Code: Select all

#include "hmg.ch"
#include "hbzebra.ch"

#xtranslate @ <Row> , <Col> PRINT ZEBRA <cCode> ;
	<cType : EAN13,EAN8,UPCA,UPCE,CODE39,ITF,MSI,CODABAR,CODE93,CODE11,CODE128,PDF417,DATAMATRIX,QRCODE> ;
	<lWidth : LINEWIDTH> <nLineWidth> ;
	<lHeight : HEIGHT> <nHeight> ;
	[ <lShowDigits : DIGITS> ] ;
	[ <lCheckSum : CHECKSUM> ] ;
	[ <Wide : WIDE2.5,WIDE3> ] ;
	[ <align : CENTER,RIGHT> ] ;
	=> ;
	PrintDrawBarcode( <Row> , <Col>, <cCode>, <"cType">, <nLineWidth>, <nHeight>, <.lShowDigits.>, <.lCheckSum.>, IF ( hb_IsNil ( <"Wide"> ) , .F. , AllTrim( <"Wide"> ) == "WIDE2.5" ) , IF ( hb_IsNil ( <"Wide"> ) , .F. , AllTrim( <"Wide"> ) == "WIDE3" ) , IF ( hb_IsNil ( <"align"> ) , 'L', Left ( <"align">, 1 ) )  )

MEMVAR _HMG_SYSDATA

*------------------------------------------------------------------------------*
Function Main()
*------------------------------------------------------------------------------*


	DEFINE WINDOW Win_1 ;
		AT 0,0 ;
		WIDTH 400 ;
		HEIGHT 400 ;
		TITLE 'Zebra Barcodes Print Library Test' ;
		MAIN 

		DEFINE MAIN MENU 
			DEFINE POPUP 'File'
				MENUITEM 'Default Printer' ACTION PrintTest1()
				MENUITEM 'User Selected Printer' ACTION PrintTest2()
				MENUITEM 'User Selected Printer And Settings' ACTION PrintTest3()
				MENUITEM 'User Selected Printer And Settings (Preview)' ACTION PrintTest4()
			END POPUP
		END MENU

	END WINDOW

	MAXIMIZE WINDOW Win_1

	ACTIVATE WINDOW Win_1

Return
*------------------------------------------------------------------------------*
Procedure PrintTest1()
*------------------------------------------------------------------------------*
Local i 

	SELECT PRINTER DEFAULT ;
		ORIENTATION	PRINTER_ORIENT_PORTRAIT ;
		PAPERSIZE	PRINTER_PAPER_LETTER ;
		QUALITY		PRINTER_RES_MEDIUM 

	PrintDoc()

	MsgInfo('Print Finished')

Return
*------------------------------------------------------------------------------*
Procedure PrintTest2()
*------------------------------------------------------------------------------*
Local i 
Local cPrinter

	cPrinter := GetPrinter()

	If Empty (cPrinter)
		Return
	EndIf

	SELECT PRINTER cPrinter ;
		ORIENTATION	PRINTER_ORIENT_PORTRAIT ;
		PAPERSIZE	PRINTER_PAPER_LETTER ;
		QUALITY		PRINTER_RES_MEDIUM

	PrintDoc()

	MsgInfo('Print Finished')

Return
*------------------------------------------------------------------------------*
Procedure PrintTest3()
*------------------------------------------------------------------------------*
Local i 
Local lSuccess

	// Measure Units Are Millimeters

	SELECT PRINTER DIALOG TO lSuccess 

	If lSuccess == .T.
		PrintDoc()
		MsgInfo('Print Finished')
	EndIf

Return
*------------------------------------------------------------------------------*
Procedure PrintTest4()
*------------------------------------------------------------------------------*
Local i 
Local lSuccess

	SELECT PRINTER DIALOG TO lSuccess PREVIEW 
	If lSuccess == .T.
		PrintDoc()
		MsgInfo('Print Finished')
	EndIf

Return
*------------------------------------------------------------------------------*
Procedure PrintDoc
*------------------------------------------------------------------------------*
Local i

	// Measure Units Are Millimeters

	START PRINTDOC


			START PRINTPAGE

				@ 20,110 PRINT "Zebra barcodes sample" FONT "Arial" SIZE 18 CENTER
			
				@ 30,20 PRINT "EAN13 Left" FONT "Arial" SIZE 12
				@ 35,15 PRINT RECTANGLE TO 65,58 PENWIDTH 0.1 ROUNDED 
				@ 40,20 PRINT ZEBRA "5059018146366" EAN13 LINEWIDTH 0.35 HEIGHT 20 DIGITS 
		

				//==========
				
				@ 30,110 PRINT "EAN13 Center with checksum" FONT "Arial" SIZE 12 CENTER
				@ 35,88 PRINT RECTANGLE TO 65,132 PENWIDTH 0.1	COLOR {255,255,0} FILLED ROUNDED 
				@ 40,110 PRINT ZEBRA "7790310983195" EAN13 LINEWIDTH 0.35 HEIGHT 20 DIGITS CHECKSUM CENTER

				//==========

				@ 30,200 PRINT "EAN13 Right w/o digits" FONT "Arial" SIZE 12 RIGHT
				@ 35,157 PRINT RECTANGLE TO 65,200 PENWIDTH 0.1	COLOR {0,255,0} FILLED ROUNDED 
				@ 40,195 PRINT ZEBRA "5059018146366" EAN13 LINEWIDTH 0.35 HEIGHT 20 RIGHT
				
				//==========
					
				@ 80,20 PRINT "EAN8 Left" FONT "Arial" SIZE 12
				@ 85,15 PRINT RECTANGLE TO 115,58 PENWIDTH 0.1 ROUNDED 
				@ 90,20 PRINT ZEBRA "59023456" EAN8 LINEWIDTH 0.35 HEIGHT 20 DIGITS
				//==========
				
				@ 80,110 PRINT "EAN8 Center with checksum" FONT "Arial" SIZE 12 CENTER
				@ 85,88 PRINT RECTANGLE TO 115,132 PENWIDTH 0.1	COLOR {255,255,0} FILLED ROUNDED 
				@ 90,110 PRINT ZEBRA "5902345" EAN8 LINEWIDTH 0.35 HEIGHT 20 DIGITS CHECKSUM CENTER

				//==========

				@ 80,200 PRINT "EAN8 Right w/o digits" FONT "Arial" SIZE 12 RIGHT
				@ 85,157 PRINT RECTANGLE TO 115,200 PENWIDTH 0.1	COLOR {0,255,0} FILLED ROUNDED 
				@ 90,195 PRINT ZEBRA "59023456" EAN8 LINEWIDTH 0.35 HEIGHT 20 RIGHT
				
				//==========

				@ 130,20 PRINT "CODE39 Left" FONT "Arial" SIZE 12
				@ 135,15 PRINT RECTANGLE TO 165,65 PENWIDTH 0.1 ROUNDED 
				@ 140,20 PRINT ZEBRA "VIVAHMG" CODE39 LINEWIDTH 0.35 HEIGHT 20 DIGITS 

				//==========
				
				@ 130,110 PRINT "CODE39 Center with checksum" FONT "Arial" SIZE 12 CENTER
				@ 135,83 PRINT RECTANGLE TO 165,137 PENWIDTH 0.1	COLOR {255,255,0} FILLED ROUNDED 
				@ 140,110 PRINT ZEBRA "VIVAHMG" CODE39 LINEWIDTH 0.35 HEIGHT 20 DIGITS CHECKSUM CENTER
				//PrintDrawBarcode( 140 , 110, "VIVAHMG", "CODE39", 0.35 , 20 , .T., .T., .F., .F., 'C')

				//==========

				@ 130,200 PRINT "CODE39 Right w/o digits" FONT "Arial" SIZE 12 RIGHT
				@ 135,150 PRINT RECTANGLE TO 165,200 PENWIDTH 0.1	COLOR {0,255,0} FILLED ROUNDED 
				@ 140,195 PRINT ZEBRA "VIVAHMG" CODE39 LINEWIDTH 0.35 HEIGHT 20 RIGHT
				
				//==========
				

				@ 180,20 PRINT "QRCODE Left" FONT "Arial" SIZE 12
				@ 185,15 PRINT RECTANGLE TO 215,65 PENWIDTH 0.1 ROUNDED 
				@ 190,20 PRINT ZEBRA "hello hello hello HMG HMG HMG viva viva viva" QRCODE LINEWIDTH 0.75 HEIGHT 0

				//==========
				
				@ 180,110 PRINT "QRCODE Center" FONT "Arial" SIZE 12 CENTER
				@ 185,83 PRINT RECTANGLE TO 215,137 PENWIDTH 0.1	COLOR {255,255,0} FILLED ROUNDED 
				@ 190,110 PRINT ZEBRA "hello hello hello HMG HMG HMG viva viva viva" QRCODE LINEWIDTH 0.75 HEIGHT 0 CENTER

				//==========

				@ 180,200 PRINT "QRCODE Right" FONT "Arial" SIZE 12 RIGHT
				@ 185,155 PRINT RECTANGLE TO 215,200 PENWIDTH 0.1	COLOR {0,255,0} FILLED ROUNDED 
				@ 190,195 PRINT ZEBRA "hello hello hello HMG HMG HMG viva viva viva" QRCODE LINEWIDTH 0.75 HEIGHT 0 RIGHT
					
												
			END PRINTPAGE

			
	END PRINTDOC


Return

**********************************************************
PROCEDURE PrintDrawBarcode( nRow, nCol, cCode, cType, nLineWidth, nLineHeight, lShowDigits, lCheckSum, lWide2_5, lWide3, cAlign )

Local hZebra, cTxt, nFlags, nSizeWidth, nTextWidth, lRet := .T.
Local cFont       := "Arial"
Local nFontSize   := 10
Local nTextHeight := 0 

DEFAULT nLineWidth  := 1
DEFAULT nLineHeight := 18
DEFAULT lCheckSum   := .F.
DEFAULT lWide2_5    := .F.
DEFAULT lWide3      := .F.
DEFAULT lShowDigits := .F.
DEFAULT cAlign      := 'L'

nFlags := 0
IF lChecksum
	nFlags := nFlags + HB_ZEBRA_FLAG_CHECKSUM
ENDIF
IF lWide2_5
	nFlags := nFlags + HB_ZEBRA_FLAG_WIDE2_5
ENDIF
IF lWide3
	nFlags := nFlags + HB_ZEBRA_FLAG_WIDE3
ENDIF
     
IF nFlags == 0
	nFlags := Nil
ENDIF

IF !UPPER(cAlign)$'LRC'
	cAlign:='L'
ENDIF

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

IF hZebra != NIL
	IF hb_zebra_geterror( hZebra ) == 0

		nSizeWidth  := HMG_Zebra_GetWidth  (hZebra, nLineWidth, nLineHeight, NIL)
		nSizeHeight := HMG_Zebra_GetHeight (hZebra, nLineWidth, nLineHeight, NIL)
		
		SWITCH UPPER(cAlign)
			CASE "L"	; EXIT																				//Left
			CASE "R"  ; nCol -= nSizeWidth; EXIT		//Right
			CASE "C"  ; nCol -= ( nSizeWidth / 2 ); EXIT 	//Center
		ENDSWITCH
				

		IF lShowDigits
			cTxt := ALLTRIM(hb_zebra_getcode( hZebra ))
			nTextHeight := GetTxtHeight( cTxt, cFont, nFontSize)
			@ nRow + nLineHeight - nTextHeight + 0.1, nCol + ( nSizeWidth / 2) PRINT cTxt FONT cFont SIZE nFontSize CENTER
		ENDIF
		
		IF hb_zebra_draw_print( hZebra, nCol ,  nRow + nSizeHeight - nTextHeight, nLineWidth, -( nLineHeight - nTextHeight ) ) # 0
			lRet := .F.
			MsgStop ("Type "+ cType + CRLF +"Code "+ cCode+ CRLF+ "Error  "+zebra_error_info(hb_zebra_geterror(hZebra)))
		ENDIF
		
	ELSE
	
		lRet := .F.
		MsgStop ("Type "+ cType + CRLF +"Code "+ cCode+ CRLF+ "Error  "+zebra_error_info(hb_zebra_geterror(hZebra)))
	
	ENDIF
	
	hb_zebra_destroy( hZebra )
ELSE
	lRet := .F.
	MsgStop("Invalid barcode type !", cType)
ENDIF
RETURN lRet

***************************************
Function Zebra_error_info(nErr)
Local cInfo:='Unknown error ('+ALLTRIM(STR(nErr))+')'
SWITCH nErr
	CASE 1      ; cInfo:='Invalid barcode (1)'   ; EXIT
	CASE 2      ; cInfo:='Invalid checksum barcode (2)'    ; EXIT
	CASE 3      ; cInfo:='Error TOOLARGE (3)'    ; EXIT
	CASE 4      ; cInfo:='Argument error (4)'  ; EXIT
ENDSWITCH
RETURN cInfo
***************************************
FUNCTION hb_zebra_draw_print( hZebra, ... )

IF hb_zebra_geterror( hZebra ) != 0
	RETURN HB_ZEBRA_ERROR_INVALIDZEBRA
ENDIF

hb_zebra_draw( hZebra, {| x, y, w, h | _HMG_PRINTER_H_RECTANGLE ( _HMG_SYSDATA [ 374 ] , y , x ,  y + h , x + w , 0 , 0 , 0 , 0 , .T. , .F. , .T.) }, ... )

RETURN 0 

******************************************************
*-----------------------------------------------------------------------------------------------*
STATIC FUNCTION HMG_Zebra_GetWidth (hZebra, nLineWidth, nLineHeight, iFlags)
*-----------------------------------------------------------------------------------------------*
LOCAL x1:= 0, y1 := 0, nBarWidth := 0, nBarHeight := 0
   // always --> nBarHeight = nLineHeight
   IF hb_zebra_GetError( hZebra ) != 0
      RETURN HB_ZEBRA_ERROR_INVALIDZEBRA
   ENDIF
// hb_zebra_draw ( hZebra,   bCodeBlock,                                            dX, dY,     dWidth,     dHeight, iFlags )
   hb_zebra_draw ( hZebra, {| x, y, w, h | nBarWidth:=x+w-x1, nBarHeight:=y+h-y1 }, x1, y1, nLineWidth, nLineHeight, iFlags )
RETURN nBarWidth


*-----------------------------------------------------------------------------------------------*
STATIC FUNCTION HMG_Zebra_GetHeight (hZebra, nLineWidth, nLineHeight, iFlags)
*-----------------------------------------------------------------------------------------------*
LOCAL x1:= 0, y1 := 0, nBarWidth := 0, nBarHeight := 0
   // always --> nBarHeight = nLineHeight
   IF hb_zebra_GetError( hZebra ) != 0
      RETURN HB_ZEBRA_ERROR_INVALIDZEBRA
   ENDIF
// hb_zebra_draw ( hZebra,   bCodeBlock,                                            dX, dY,     dWidth,     dHeight, iFlags )
   hb_zebra_draw ( hZebra, {| x, y, w, h | nBarWidth:=x+w-x1, nBarHeight:=y+h-y1 }, x1, y1, nLineWidth, nLineHeight, iFlags )
RETURN nBarHeight

**************************************************************************************************
FUNCTION GetTxtHeight( cText, cFontName, nFontSize, lBold, lItalic, lUnderline, lStrikeout )
RETURN HMG_GethDCTextHeightinMM( OpenPrinterGetPagedc(), cText, cFontName, nFontSize, lBold, lItalic, lUnderline, lStrikeout )

**************************************************************************************************
FUNCTION HMG_GethDCTextHeightInMM( hDC, cText, cFontName, nFontSize, lBold, lItalic, lUnderline, lStrikeout )
RETURN ( HMG_GethDCTextHeightInPx( hDC, cText, cFontName, nFontSize, lBold, lItalic, lUnderline, lStrikeout ) * 25.4 ) / HMG_GetPrinterResolution( hDC ) [ 2 ]

**************************************************************************************************
FUNCTION HMG_GethDCTextHeightInPx( hDC, cText, cFontName, nFontSize, lBold, lItalic, lUnderline, lStrikeout )

LOCAL hFont
   DEFAULT cText := ""
   DEFAULT cFontName := _HMG_SYSDATA[ 342 ]
   DEFAULT nFontSize := _HMG_SYSDATA[ 343 ]
   DEFAULT lItalic := .F.
   DEFAULT lUnderline := .F.
   DEFAULT lStrikeout := .F.
   DEFAULT lBold := .F.

   hFont := HMG_CreateFont( hDC, cFontName, nFontSize, lBold, lItalic, lUnderline, lStrikeOut )
   RETURN GetTextHeight( hDC, cText, hFont )

**********************************************************************
//thanks goes to MOL (Marek Olszewski)
#pragma begindump
#include <windows.h>
#include <hbapi.h>

   HB_FUNC( HMG_GETPRINTERRESOLUTION )
   {
   hb_reta( 2 ) ;
            hb_storvni( GetDeviceCaps( ( HDC ) hb_parnl( 1 ), LOGPIXELSX ), - 1, 1 ) ;
            hb_storvni( GetDeviceCaps( ( HDC ) hb_parnl( 1 ), LOGPIXELSY ), - 1, 2 ) ;
            }
#pragma ENDDUMP

test-1.jpg
test-1.jpg (248.97 KiB) Viewed 1493 times
Last edited by edk on Fri Apr 30, 2021 9:30 pm, edited 1 time in total.
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Ayuda con report

Post by Claudio Ricardo »

Thank you very much Edward...
It is perfect to create the adhesive labels for the products that do not bring or when they are divided.
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: Ayuda con report

Post by SALINETAS24 »

mjaviergutierrez wrote: Wed Apr 28, 2021 10:02 pm Hola Amigos, tengo el siguiente reporte que recorre una tabla que se llama ETIQUETAS.DBF, imprime precios para las gondolas de supermercado, tiene tres columnas definindas , en cada etiqueta imprime :
arriba el nombre del producto,
en la linea siguiente el precio en un letra mas grande,
en la linea siguiente una imagen JPG con el codigo de barras (el nombre de la imagen varia para cada registro, y el nombre está en el campo CBARRA1,CBARRA2,CBARRA3)
y en la linea siguiente un texto con el codigo de barras .....
Hola mjaviergutierrez...,

Aquí te paso una posible solución..

El problema se origina en h_rptgen.prg, imagino que cuando se creo esta parte de la librería no se pensó que IMAGEN podría cambia y al cargar la primera ya no recarga las siguientes.

He hecho una copia del progarma h_rptgen.prg y he incluido estas lineas

Code: Select all

	IF AT("->",cValue)!=0
				cValue := &cValue
	ENDIF
en el PROC _PrintImage( aObject , nOffset ), aproximadamente lineas 1172 a 1174.

y lo que hago es un INCLUDE en tu programa MAIN del

Code: Select all

	#include <hmg.ch>
	#include <h_rptgen.prg>
y en la definicion de IMAGEN

Code: Select all

				BEGIN PICTURE
					VALUE "ETIQUETA->CBARRA1"
					ROW 22
					COL 24
					WIDTH 30
					HEIGHT 7
					STRETCH .T.

				END PICTURE

pongo el VALUE "ENTRE COMILLAS".

y yasta.

Me ha costado un poco he tenido que contruir las DBF... (no las pasaste :| ), yo si las incluyo en mi ejemplo :lol:

Y ahora vamos con una cervecita fresquita, saludos cordiales.
Attachments
Temp.rar
(1.45 MiB) Downloaded 100 times
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
Post Reply