Impresion de Imagenes con TPRINTER

Post Reply
User avatar
JoseAlvarez
Posts: 811
Joined: Sun Nov 09, 2014 5:01 pm

Impresion de Imagenes con TPRINTER

Post by JoseAlvarez »

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.
Dioni
Posts: 37
Joined: Tue May 12, 2009 8:45 pm
Location: Lima - Perú

Re: Impresion de Imagenes con TPRINTER

Post by Dioni »

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
User avatar
nageswaragunupudi
Posts: 10722
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Impresion de Imagenes con TPRINTER

Post by nageswaragunupudi »

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: Select all | Expand


#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: Select all | Expand


@ 2,2 PTINT TO oPrn IMAGE <anyimagefilename> SIZE 2,3 INCHES
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
Sebastián Almirón
Posts: 159
Joined: Mon Dec 12, 2005 9:56 am
Location: Moralzarzal - Spain
Been thanked: 1 time

Re: Impresion de Imagenes con TPRINTER

Post by Sebastián Almirón »

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: Select all | Expand

//------------------------------------------------------------------------------
// 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
User avatar
nageswaragunupudi
Posts: 10722
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Impresion de Imagenes con TPRINTER

Post by nageswaragunupudi »

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: Select all | Expand

//------------------------------------------------------------------------------
// 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
User avatar
karinha
Posts: 7942
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: Impresion de Imagenes con TPRINTER

Post by karinha »

De esta manera, también se ve genial.

Code: Select all | Expand


      @ 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
User avatar
nageswaragunupudi
Posts: 10722
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Impresion de Imagenes con TPRINTER

Post by nageswaragunupudi »

karinha wrote:De esta manera, también se ve genial.

Code: Select all | Expand


      @ 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
User avatar
karinha
Posts: 7942
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: Impresion de Imagenes con TPRINTER

Post by karinha »

nageswaragunupudi wrote:
karinha wrote:De esta manera, también se ve genial.

Code: Select all | Expand


      @ 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
User avatar
JoseAlvarez
Posts: 811
Joined: Sun Nov 09, 2014 5:01 pm

Re: Impresion de Imagenes con TPRINTER SOLUCIONADO

Post by JoseAlvarez »

Hola A todos.

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

Mr. Rao, esto

Code: Select all | Expand

@ 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: Select all | Expand

@ 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.
Post Reply