Impresion de Imagenes con TPRINTER

Impresion de Imagenes con TPRINTER

Postby JoseAlvarez » Sun Jun 27, 2021 3: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.
User avatar
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm

Re: Impresion de Imagenes con TPRINTER

Postby Dioni » Mon Jun 28, 2021 2: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
Dioni
 
Posts: 36
Joined: Tue May 12, 2009 8:45 pm
Location: Lima - Perú

Re: Impresion de Imagenes con TPRINTER

Postby nageswaragunupudi » Mon Jun 28, 2021 3: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: Select all  Expand view

#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 view

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Impresion de Imagenes con TPRINTER

Postby Sebastián Almirón » Mon Jun 28, 2021 8: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: Select all  Expand view
//------------------------------------------------------------------------------
// 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
Sebastián Almirón
 
Posts: 155
Joined: Mon Dec 12, 2005 9:56 am
Location: Moralzarzal - Spain

Re: Impresion de Imagenes con TPRINTER

Postby nageswaragunupudi » Mon Jun 28, 2021 9: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: Select all  Expand view
//------------------------------------------------------------------------------
// 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
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Impresion de Imagenes con TPRINTER

Postby karinha » Mon Jun 28, 2021 3:03 pm

De esta manera, también se ve genial.

Code: Select all  Expand view

      @ 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
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Impresion de Imagenes con TPRINTER

Postby nageswaragunupudi » Mon Jun 28, 2021 4:00 pm

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

Code: Select all  Expand view

      @ 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
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Impresion de Imagenes con TPRINTER

Postby karinha » Mon Jun 28, 2021 4:20 pm

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

Code: Select all  Expand view

      @ 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
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Impresion de Imagenes con TPRINTER SOLUCIONADO

Postby JoseAlvarez » Wed Jun 30, 2021 8:18 pm

Hola A todos.

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

Mr. Rao, esto
Code: Select all  Expand view
@ 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 view
@ 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.
User avatar
JoseAlvarez
 
Posts: 726
Joined: Sun Nov 09, 2014 5:01 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 79 guests