FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Impresion de Imagenes con TPRINTER
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Impresion de Imagenes con TPRINTER
Posted: Sun Jun 27, 2021 03:19 PM

Hola a todos, feliz domingo.

Dejo esta consulta por acá a ver quien me da una mano.
Necesito imprimir el logo de la empresa del cliente en los reportes de mi sistema con la clase TPRINTER.
Se me presenta el problema con las diferentes resoluciones de impresoras. No se imprime igual
En algunas se ve como debe verse, en otras mas grande o mas pequeño,
Hace dias consulte como hacer lo mismo con los textos y con la ayuda de joao y francisco lo resolví.
Pero ahora el problema lo tengo con las imagenes.

Quedo a la espera y agradezco la ayuda que puedan prestarme.

FW17.01 + bcc7 + xHarbour

"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: 37
Joined: Tue May 12, 2009 08:45 PM
Re: Impresion de Imagenes con TPRINTER
Posted: Mon Jun 28, 2021 02:54 AM

oPrn:PrintImage(0,0,"dioni.png",580,240) <------ formato bmp,jpg, otros

Esto trabaja perfectamente en impresoras de tinta, lasser, ticketera y puedes grabarlo en formato pdf para visualizarlo
y luego el usuario podra selecionar cuanquier impresora y podra imprimir respetando el tamaño y colo que tenga.

o deja tu programa donde utilizas la impresion... para ver la falla

Te recomiendo actualizar tu fivewin 17.01 a fivewin 21.06

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Impresion de Imagenes con TPRINTER
Posted: Mon Jun 28, 2021 03:12 AM
Method PrintImage() works with FWH1701 also.
But we do not recomment using pixels for the size. Instead we recommend using Inches/CM/MM for the size so that the image will print with the same dimensions irrespective of the printer resolution.
So we recommend using this command which translates to PrintImage()

Code (fw): Select all Collapse
#xcommand @ <nRow>, <nCol> PRINT TO <prn> IMAGE <img> ;
      [SIZE <nWidth> [,<nHeight>] ] ;
      [<unit: PIXEL,MM,CM,INCHES>] ;
      [<lStr: STRETCH>] ;
      [ ALPHALEVEL <nAlpha>] ;
      [<lNoTrn: NOTRANSPARENT>] ;
      [<lGray: GRAY> ] ;
      [LASTROW <lrow>] ;
   => ;
      [<lrow> := ] <prn>:PrintImage( <nRow>, <nCol>, <img>, [<nWidth>], [<nHeight>], ;
            [<.lStr.>], [<nAlpha>], [!<.lNoTrn.>], [<.lGray.>], [<(unit)>] )


Example Usage:
Code (fw): Select all Collapse
@ 2,2 PTINT TO oPrn IMAGE <anyimagefilename> SIZE 2,3 INCHES
Regards



G. N. Rao.

Hyderabad, India
Posts: 166
Joined: Mon Dec 12, 2005 09:56 AM
Re: Impresion de Imagenes con TPRINTER
Posted: Mon Jun 28, 2021 08:19 AM
Yo tuve muchos problemas con eso al principio, desde hace mas de 15 años adjunto a mis programas estas dos pequeñas funciones y a partir de ellas paso todos los parametros en centimetros con decimales, me funciona muy bien.
Por ejemplo :
oimagen := TImage():Define(logo.jpg')
oPrint:SayImage(Posx(nposx) , Posy(nposy) , oimagen, posx(nancho), posy(nalto))
Code (fw): Select all Collapse
//------------------------------------------------------------------------------
// Posx(valor)
//
// Devuelve la posicion logica x expresada en centimetos en valor del objeto
// tprinter oPrint
//
function posx(valor, oxPrint)
local sal
DEFAULT oxPrint := oPrint
if oxPrint:hdc = 0
    sal := Max( 0,  valor * 14 * oxPrint:nVertRes() / oxPrint:nVertSize()    - oxPrint:nXoffset ) + 15
else
    sal := valor*(oxPrint:nLogPixelX()/2.6)
endif
return sal


//------------------------------------------------------------------------------
// Posy(valor)
//
// Devuelve la posicion logica y expresada en centimetos en valor del objeto
// tprinter oPrint
//
function Posy(valor, oxPrint)
local sal
DEFAULT oxPrint := oPrint
if oxPrint:hdc = 0
    sal := Max( 0, ( valor * 9.4 * oxPrint:nHorzRes() / oxPrint:nHorzSize() ) - oxPrint:nYoffset )
else
    sal := valor*(oxPrint:nLogPixelY()/2.6)
endif
return sal
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Impresion de Imagenes con TPRINTER
Posted: Mon Jun 28, 2021 09:55 AM
Sebastián Almirón wrote:Yo tuve muchos problemas con eso al principio, desde hace mas de 15 años adjunto a mis programas estas dos pequeñas funciones y a partir de ellas paso todos los parametros en centimetros con decimales, me funciona muy bien.
Por ejemplo :
oimagen := TImage():Define(logo.jpg')
oPrint:SayImage(Posx(nposx) , Posy(nposy) , oimagen, posx(nancho), posy(nalto))
Code (fw): Select all Collapse
//------------------------------------------------------------------------------
// Posx(valor)
//
// Devuelve la posicion logica x expresada en centimetos en valor del objeto
// tprinter oPrint
//
function posx(valor, oxPrint)
local sal
DEFAULT oxPrint := oPrint
if oxPrint:hdc = 0
    sal := Max( 0,  valor * 14 * oxPrint:nVertRes() / oxPrint:nVertSize()    - oxPrint:nXoffset ) + 15
else
    sal := valor*(oxPrint:nLogPixelX()/2.6)
endif
return sal


//------------------------------------------------------------------------------
// Posy(valor)
//
// Devuelve la posicion logica y expresada en centimetos en valor del objeto
// tprinter oPrint
//
function Posy(valor, oxPrint)
local sal
DEFAULT oxPrint := oPrint
if oxPrint:hdc = 0
    sal := Max( 0, ( valor * 9.4 * oxPrint:nHorzRes() / oxPrint:nHorzSize() ) - oxPrint:nYoffset )
else
    sal := valor*(oxPrint:nLogPixelY()/2.6)
endif
return sal


All this is not necessary if you follow the advice of FiveTech given in my posting above.
Regards



G. N. Rao.

Hyderabad, India
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Impresion de Imagenes con TPRINTER
Posted: Mon Jun 28, 2021 03:03 PM
De esta manera, también se ve genial.

Code (fw): Select all Collapse
      @ nLinLogo, nColLogo PRINT TO oPrn IMAGE "LOGO.JPG" ;
         SIZE nLargLogo, nAltLogo PIXEL ALPHALEVEL 90


Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Impresion de Imagenes con TPRINTER
Posted: Mon Jun 28, 2021 04:00 PM
karinha wrote:De esta manera, también se ve genial.

Code (fw): Select all Collapse
      @ nLinLogo, nColLogo PRINT TO oPrn IMAGE "LOGO.JPG" ;
         SIZE nLargLogo, nAltLogo PIXEL ALPHALEVEL 90


Saludos.


We highly discourage using PIXEL. This may differ with different printers and totally not compatible with pdf generation using harupdf.

Please express all coordinates in inches or cm or mm and specify the units as INCHES or CM or MM instead of PIXEL
Regards



G. N. Rao.

Hyderabad, India
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Impresion de Imagenes con TPRINTER
Posted: Mon Jun 28, 2021 04:20 PM
nageswaragunupudi wrote:
karinha wrote:De esta manera, también se ve genial.

Code (fw): Select all Collapse
      @ nLinLogo, nColLogo PRINT TO oPrn IMAGE "LOGO.JPG" ;
         SIZE nLargLogo, nAltLogo PIXEL ALPHALEVEL 90


Saludos.


We highly discourage using PIXEL. This may differ with different printers and totally not compatible with pdf generation using harupdf.

Please express all coordinates in inches or cm or mm and specify the units as INCHES or CM or MM instead of PIXEL



Thank you master, I didn't know that. Living and learning.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 851
Joined: Sun Nov 09, 2014 05:01 PM
Re: Impresion de Imagenes con TPRINTER SOLUCIONADO
Posted: Wed Jun 30, 2021 08:18 PM
Hola A todos.

Gracias a quienes contestaron a mi inquietud y al foro FW.

Mr. Rao, esto
Code (fw): Select all Collapse
@ 2,2 PRINT TO oPrn IMAGE <anyimagefilename> SIZE 2,3 INCHES


me arroja el siguiente error

Error description: Warning BASE/1004 Message not found: TPRINTER:PRINTIMAGE

¿que estoy haciendo mal?


Joao, lo que me indicaste

Code (fw): Select all Collapse
@ nLinLogo, nColLogo PRINT TO oPrn IMAGE "LOGO.JPG" ;
         SIZE nLargLogo, nAltLogo PIXEL ALPHALEVEL 90


funcionó muy bien y a la primera en todas las impresoras que probé, GRACIAS !!

Sebastián, las funciones y el ejemplo que pusiste funcionó de 10 y a la primera. Muchas Gracias !!
Para mi forma de trabajar, me quedo con la sugerencia de sebastian. Se adapta mejor a mis metodos.

Un Saludo a Todos.
"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.

Continue the discussion