FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour color en fuentes de haruPDF (SOLUCIONADO)
Posts: 203
Joined: Tue Oct 11, 2005 02:17 PM
color en fuentes de haruPDF (SOLUCIONADO)
Posted: Sat Apr 06, 2019 09:46 AM
Alguien usa HARUPdf
Estoy intentando utilizar esta clase pero al indicar una fuente de un color determinado con algunos colores me los cambia.
Pongo un ejemplo

Code (fw): Select all Collapse
#define HPDF_COMP_ALL 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 0x0F
// HPDF_TextAlignment
#define HPDF_TALIGN_LEFT 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽0
#define HPDF_TALIGN_RIGHT 聽 聽 聽 聽 聽 聽 聽 聽 聽 1
#define HPDF_TALIGN_CENTER 聽 聽 聽 聽 聽 聽 聽 聽 聽2
#define HPDF_TALIGN_JUSTIFY 聽 聽 聽 聽 聽 聽 聽 聽 3

#DEFINE AZUL聽 聽 CLR_BLUE聽 聽 //16711680
#DEFINE ROJO聽 聽 CLR_RED聽聽 聽 //255
#DEFINE VERDE聽 聽CLR_GREEN聽 聽//65280

STATIC FUNCTION TestHaru()
Local oPrint, oFont
oPrint := THaruPdf():New(".\pdf\testharu.pdf", NIL, NIL, NIL, .T., NIL)
oPrint:SetCompression( HPDF_COMP_ALL )
oFont := oPrint:DefineFont( 'Arial', 10 )

oPrint:StartPage()
WITH OBJECT oPrint
聽 聽 //METHOD CmRect( nTop, nLeft, nBottom, nRight, oPen, nColor )
聽 聽 :CmSay( 04.02, 10.2, "AZUL", 聽oFont, 5.0,AZUL 聽 聽 ,, HPDF_TALIGN_LEFT )
聽 聽 :CmSay( 04.02, 12.2, "HBLUE", oFont, 5.0,CLR_HBLUE,, HPDF_TALIGN_LEFT )

聽 聽 :CmSay( 04.52, 10.2, "VERDE", 聽oFont, 5.0,VERDE 聽 ,, HPDF_TALIGN_LEFT )
聽 聽 :CmSay( 05.02, 10.2, "ROJO", 聽 oFont, 5.0,ROJO 聽 聽,, HPDF_TALIGN_LEFT )
聽 聽 :CmSay( 05.52, 10.2, "GRAY", 聽 oFont, 5.0,CLR_GRAY,, HPDF_TALIGN_LEFT )
聽 聽 :CmSay( 05.52, 10.2, "GRAY", 聽 oFont, 5.0,CLR_GRAY,, HPDF_TALIGN_LEFT )
聽 聽 :CmSay( 06.02, 10.2, "YELLOW", oFont, 5.0,CLR_YELLOW,, HPDF_TALIGN_LEFT )


聽 聽 :CmRect( 08.0, 10.0, 09, 16, 1, CLR_HBLUE)
聽 聽 聽:CmSay( 08.2, 10.2, "HBLUE 8,10, 09,16", oFont, 5.0,CLR_HBLUE,, HPDF_TALIGN_LEFT )

聽 聽 :CmRect( 10.0, 10.0, 11, 16, 2, CLR_HRED)
聽 聽 聽:CmSay( 10.2, 10.2, "HRED 10,10, 11,16", oFont, 5.0,CLR_RED, HPDF_TALIGN_LEFT )

聽 聽 //RoundBox( nTop, nLeft, nBottom, nRight, nWidth, nHeight, oPen, nColor, nBackColor )
聽 聽 聽:CMRoundBox( 聽 14, 聽 聽10, 聽 聽 聽15, 聽 聽 12, 聽 聽 0.1, 聽 聽 0.1, 聽 聽3, 聽CLR_HGREEN, 聽 聽 聽 聽CLR_YELLOW)
END

oPrint:EndPage()
oprint:eND()
RETURN NIL


Alguna pista
Gracias
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: color en fuentes de haruPDF
Posted: Sat Apr 06, 2019 10:31 AM
Es raro, a mi me funciona bien, y en tu c贸digo no veo nada que indique que lo est茅s haciendo mal
Puedes poner una imagen?
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 203
Joined: Tue Oct 11, 2005 02:17 PM
Re: color en fuentes de haruPDF
Posted: Sat Apr 06, 2019 03:45 PM

Perd贸n por la ignorancia
驴Existe alguna forma de poner una imagen en un mensaje sin necesidad de subirla a alg煤n servidor externo?
Si solo se puede a trav茅s de un servidor.
驴Que servidores me recomend谩is?

Un saludo

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: color en fuentes de haruPDF
Posted: Sat Apr 06, 2019 03:55 PM
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 203
Joined: Tue Oct 11, 2005 02:17 PM
Re: color en fuentes de haruPDF
Posted: Sun Apr 07, 2019 09:13 AM
gracias

La imagen del pdf que se genera es esta

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: color en fuentes de haruPDF
Posted: Sun Apr 07, 2019 10:48 AM
Pues no entiendo el motivo, tu ejemplo parece funcionar correctamente

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 203
Joined: Tue Oct 11, 2005 02:17 PM
Re: color en fuentes de haruPDF
Posted: Mon Apr 08, 2019 05:57 AM

Gracias, voy a probar a realizar un ejemplo aislado del programa en el que estoy trabajando.

Posts: 203
Joined: Tue Oct 11, 2005 02:17 PM
Re: color en fuentes de haruPDF
Posted: Tue Apr 09, 2019 06:25 PM
Hola de nuevo
He probado a descargar de nuevo la libreria y a montar otro ejemplo pero los colores siguen saliendo cambiados

La libreria la descargo desde https://bitbucket.org/carlos_mora/pdfprinter 驴ser谩 esta la correcta?

Si utilizo los metodos cmSAyBitmap() o cmRect() no obtengo ninguna salida
pero Si enlazo en lugar de usar png.lib de la librer铆a uso png.lib de harbour si funciona el metodo cmsaybitmap()
el m茅todo cmRect lo ten铆a reprogramado creando cuatro lineas...

Estar茅 mezclando librrer铆as incompatibles

Esta es la salida que obtengo con el ejemplo que tiene la libreria
Gracias

Posts: 203
Joined: Tue Oct 11, 2005 02:17 PM
Re: color en fuentes de haruPDF
Posted: Wed Apr 10, 2019 06:36 PM
Al final lo he solucionado con un parche aunque no me gusta
He modificado los m茅todos de la clase y en la selecci贸n del color hago la llamada a una funci贸n que ajusta los colores a lo que me sale impreso

Code (fw): Select all Collapse
...
聽 聽 聽 nClrText := Ajustacolor(nClrText)聽聽 聽 // Ajuste colores MAF
聽 聽 聽 c := HPDF_Page_GetRGBFill( ::hPage )
聽 聽 聽 HPDF_Page_SetRGBFill( ::hPage, ( Int( nClrText / 0x10000 ) % 256 ) / 256.00, ( Int( nClrText / 0x100 ) 聽% 256 ) 聽/ 256.00, ( nClrText 聽% 256 ) / 256.00 )


y estos son los ajustes

Code (fw): Select all Collapse
STATIC FUNCTION AjustaColor(nColor)
//RETURN nColor
DO CASE
聽 聽CASE nColor == CLR_RED 聽 聽; RETURN CLR_BLUE
聽 聽CASE nColor == CLR_HRED 聽 ; RETURN CLR_HBLUE
聽 聽CASE nColor == CLR_BLUE 聽 ; RETURN CLR_RED
聽 聽CASE nColor == CLR_HBLUE 聽; RETURN CLR_HRED
聽 聽CASE nColor == CLR_CYAN 聽 ; RETURN CLR_YELLOW
聽 聽CASE nColor == CLR_YELLOW ; RETURN CLR_HCYAN
聽 聽CASE nColor == CLR_HCYAN 聽; RETURN CLR_YELLOW
聽 聽CASE nColor == CLR_BROWN 聽; RETURN CLR_CYAN



ENDCASE
RETURN nColor


Un saludo y gracias a todos
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: color en fuentes de haruPDF
Posted: Wed Apr 10, 2019 07:18 PM
Prueba con esto ( quitando tu function, claro )

Code (fw): Select all Collapse
      HPDF_Page_SetRGBFill( ::hPage, ( nClrText % 256 ) / 256.00,;
                                      ( Int( nClrText / 0x100 )  % 256 )  / 256.00 , (  Int(nClrText / 0x10000 ) % 256 ) / 256.00 )
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 203
Joined: Tue Oct 11, 2005 02:17 PM
Re: color en fuentes de haruPDF
Posted: Wed Apr 10, 2019 09:05 PM

Con esta modificacion funciona correctamente
Un millon de gracias
Entiendo que en el c贸digo que descargu茅 la selecci贸n del color se pasa de forma incorrecta
Un saludo

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: color en fuentes de haruPDF
Posted: Wed Apr 10, 2019 10:20 PM
Modifica y a帽ade al titulo del primer post del hilo ( Solucionado )
Saludos
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: color en fuentes de haruPDF
Posted: Fri Apr 12, 2019 08:52 AM

Epa! Parece que se me col贸 un error. Suerte que est谩 Cristobal atento.

Voy a corregir la l铆nea en la librer铆a, es un error evidente. Parece que ninguno hasta ahora hab铆amos impreso texto en colores!
Como es c贸digo abierto, la mejor manera es que la correcci贸n se comparta, por lo que os animo a hacer la correcci贸n en una copia vuestra y hacer un "pull request" con los cambios. 隆Ganamos todos!

Un saludo

Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
鈥淚f you think education is expensive, try ignorance"
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: color en fuentes de haruPDF
Posted: Sun Apr 14, 2019 11:06 AM

Ya est谩 subida la correcci贸n al repositorio, asi es que ya se puede actualizar.
Solo se cambi贸 esa l铆nea en el prg correspondiente.
Gracias a miarcod por reportar el error y al master Cristobal por solucionarlo

Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
鈥淚f you think education is expensive, try ignorance"

Continue the discussion