THaruPdf Mastintin Edition

THaruPdf Mastintin Edition

Postby Carlos Mora » Wed Feb 22, 2017 10:38 am

Hola gente,

gracias a los aportes e ideas de Mastintin se han incorporado correciones y mejoras en esta release. Me han quedado un par de detalles sin pulir, la falta incorporar RoundBox, y a falta de pruebas lo subo para quien lo necesita usar ya.

Los cambios más importantes son:
1) La incorporación de la opción PREVIEW: es un parámetro adicional, que junto a 2 datas permiten lanzar la visualizacion del PDF con un ShellExecute, personalizable a través de un codeBlock ::bPreview.
2) Comandos para las implementaciones de impresión: Si incluímos HaruPrint.ch, se puede definir el objeto de impresión con un DEFINE

Code: Select all  Expand view

#include 'HaruPrint.ch'

IF lPorTPrinter
   
   DEFINE PRINT oPrint BLAH BLAH   // Usando los comandos de la TPrinter.ch
   
   PRINT OBJECT oPrint    // <- Nuevo
   
ELSE // Por Haru
   
   PRINT oPrint TO HARU "MyPdf.pdf" PREVIEW USER PASS "esparami" OWNER PASS "SoloYo"
   
ENDIF

   // Impresion normal, comun a las dos clases
   
   PAGE
      oPrint:Say(...)
   ENDPAGE

ENDPRINT
 


Se logra esto con el reemplazo de las funciones que controlan los comandos de impresion PAGE/ENDPAGE/ENDPRINT en HaruPrintMgr.prg

Quiero hacer notar que se pueden hacer adaptaciones al gusto personal en la clase THaruPdf sin que esto afecte el funcionamiento del resto de la librería. Esta clase está ahí justamente para poder meter código propio, sin necesidad de modificar el código de la librería propiamente dicha, con lo que podemos con mucho menos esfuerzo incorporar nuevas versiones sin perder nuestras adaptaciones, cambios, ajustes y correcciones.

Todas estas novedades vienen del trabajo del master Mastintin, por lo que esta es su edición :).
Ya está subida en BitBucket.
Por el momento, nada más. Espero que resulte útil.
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: THaruPdf Mastintin Edition

Postby karinha » Wed Feb 22, 2017 2:30 pm

Ya está subida en BitBucket.


Buén dia, donde está el link para descarga?

Gracias, 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: THaruPdf Mastintin Edition

Postby mastintin » Wed Feb 22, 2017 5:32 pm

Gracias por lo de Mastintin Edition ... :D

Hay un bug en el nuevo archivo de haruprint.ch ...
Se ve que se cambiaron los nombre de las funciones .
tendria que quedar asi :

#xcommand PAGE => PrtMgrStartPage()
#xcommand ENDPAGE => PrtMgrEndPage()

y tambien un nuevo methodo


Code: Select all  Expand view


Method SayRotate( nTop, nLeft, cTxt, oFont, nClrText, nAngle )

   LOCAL aBackColor
   LOCAL nRadian := ( nAngle / 180 ) * 3.141592 /* Calcurate the radian value. */

    IF ValType( nClrText ) == 'N'
      aBackColor:= HPDF_Page_GetRGBFill( ::hPage )
      HPDF_Page_SetRGBFill( ::hPage, ( Int( nClrText / 0x10000 ) % 256 ) / 256.00, ( Int( nClrText / 0x100 )  % 256 )  / 256.00 , ( nClrText  % 256 ) / 256.00 )
   ENDIF

   /* FONT and SIZE*/
   If !Empty( oFont )
       HPDF_Page_SetFontAndSize( ::hPage, oFont[1], oFont[2] )
   EndI

   /* Rotating text */
   HPDF_Page_BeginText( ::hPage )
   HPDF_Page_SetTextMatrix( ::hPage, cos( nRadian ),;
                                     sin( nRadian ),;
                                     -( sin( nRadian ) ),;
                                     cos( nRadian ), nLeft, HPDF_Page_GetHeight( ::hPage )-( nTop ) )
   HPDF_Page_ShowText( ::hPage, cTxt )

   IF ValType( aBackColor ) == 'A'
      HPDF_Page_SetRGBFill( ::hPage, aBackColor[1], aBackColor[2], aBackColor[3] )
   ENDIF

   HPDF_Page_EndText( ::hPage )

Return NIL

 


Saludos.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: THaruPdf Mastintin Edition

Postby Carlos Mora » Thu Feb 23, 2017 9:20 am

karinha wrote:
Ya está subida en BitBucket.


Buén dia, donde está el link para descarga?

Gracias, saludos.


viewtopic.php?f=6&t=33439

https://bitbucket.org/carlos_mora/pdfprinter

Es un repositorio GIT. Puedes clonarlo, o bien puedes descargarlos en la opción 'Downloads'

Y si necesitas ayuda, o se te ocurre algo que se pueda añadir o mejorar, será bienvenido. El diseño y la funcionalidad se impantó en función de lo que me hacía falta. Ahora que otros compañeros la usan van surgiendo nuevas necesidades.

Un saludo
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: THaruPdf Mastintin Edition

Postby Carlos Mora » Thu Feb 23, 2017 9:30 am

mastintin wrote:Gracias por lo de Mastintin Edition ... :D

Hay un bug en el nuevo archivo de haruprint.ch ...
Se ve que se cambiaron los nombre de las funciones .
tendria que quedar asi :

#xcommand PAGE => PrtMgrStartPage()
#xcommand ENDPAGE => PrtMgrEndPage()

Upps! Con las prisas, y que no lo uso.... Espero te haya parecido bien la solución alternativa. Deja usar más código compartido sin importar si es printer o Haru.

y tambien un nuevo methodo


Code: Select all  Expand view


Method SayRotate( nTop, nLeft, cTxt, oFont, nClrText, nAngle )

   LOCAL aBackColor
   LOCAL nRadian := ( nAngle / 180 ) * 3.141592 /* Calcurate the radian value. */

    IF ValType( nClrText ) == 'N'
      aBackColor:= HPDF_Page_GetRGBFill( ::hPage )
      HPDF_Page_SetRGBFill( ::hPage, ( Int( nClrText / 0x10000 ) % 256 ) / 256.00, ( Int( nClrText / 0x100 )  % 256 )  / 256.00 , ( nClrText  % 256 ) / 256.00 )
   ENDIF

   /* FONT and SIZE*/
   If !Empty( oFont )
       HPDF_Page_SetFontAndSize( ::hPage, oFont[1], oFont[2] )
   EndI

   /* Rotating text */
   HPDF_Page_BeginText( ::hPage )
   HPDF_Page_SetTextMatrix( ::hPage, cos( nRadian ),;
                                     sin( nRadian ),;
                                     -( sin( nRadian ) ),;
                                     cos( nRadian ), nLeft, HPDF_Page_GetHeight( ::hPage )-( nTop ) )
   HPDF_Page_ShowText( ::hPage, cTxt )

   IF ValType( aBackColor ) == 'A'
      HPDF_Page_SetRGBFill( ::hPage, aBackColor[1], aBackColor[2], aBackColor[3] )
   ENDIF

   HPDF_Page_EndText( ::hPage )

Return NIL

 




Que interesante! No lo había pensado eso de darle ángulo... Ese método no viene en la clase TPrinter, verdad? Al menos no está en la FW que yo tengo, que ya tiene algun tiempo...
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: THaruPdf Mastintin Edition

Postby mastintin » Thu Feb 23, 2017 6:32 pm

La solución es mucho mejor , con diferencia y incluso, el que quiera, puede modificar su printer.ch y se ahorra el PRINT OBJECT oPrint .

Que interesante! No lo había pensado eso de darle ángulo... Ese método no viene en la clase TPrinter, verdad? Al menos no está en la FW que yo tengo, que ya tiene algun tiempo...


Que yo sepa en Tprinter no está .
Creo que he encontrado otro bug ... en la "gestión de los colores "

Code: Select all  Expand view

   HPDF_Page_SetRGBStroke( ::hPage, ( Int( oPen:nColor / 0x10000 ) % 256 ) / 256.00, ( Int( oPen:nColor / 0x100 )  % 256 )  / 256.00 , ( oPen:nColor  % 256 ) / 256.00 )
 


Creo que está al revés ....
Me di cuenta porque le pase un Color con la funcion nRgb( 255, 0,0 ) -> 255 es el rojo y me lo pinto de azul .
Así que yo creo que lo correcto seria ...

Code: Select all  Expand view

   HPDF_Page_SetRGBStroke( ::hPage, (  oPen:nColor  % 256 ) / 256.00, ( Int( oPen:nColor / 0x100 )  % 256 )  / 256.00 , ( Int(oPen:nColor/  0x10000 )  % 256 ) / 256.00 )
 


Este bug esta a lo largo de toda la clase ( lógico ) donde se manejan colores ... :Say() , :Line() y rect()
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: THaruPdf Mastintin Edition

Postby mastintin » Fri Feb 24, 2017 11:57 am

creo que he localizado otro bug . Estye esta en Saybitmap ...

Code: Select all  Expand view

      /* Draw image to the canvas.(normal-mode with actual size.)*/
      //HPDF_Page_DrawImage(::hPage, image, nCol, ::nHeight - nRow - nWidth, nHeight, nWidth /* iw, ih*/)
      HPDF_Page_DrawImage(::hPage, image, nCol, ::nHeight - nRow - nHeight, nWidth,nHeight /* iw, ih*/)  // nuevo el orden de nwith, y nHeight estaba cambiado  respecto a la misma funcion en tPrinter .
 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: THaruPdf Mastintin Edition

Postby Carlos Mora » Sun Feb 26, 2017 11:01 am

Ya salió todo para el repositorio.

Lo de los colores... 'mea culpa'. Es que con esto de programar en PHP y CSS, se me ha pegado la costumbre de escribir los colores como 0xff0000, usando la representación hexadecimal , y eso me llevó a meter la pata :oops: .

Pero vino bien: hice un refactoring de todo el uso de Pen y nColor en un solo método SetPen( oPen, nColor ) y ahorramos un montón de código,

Muchas gracias!
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: THaruPdf Mastintin Edition

Postby mastintin » Mon Feb 27, 2017 8:37 am

Carlos, se ha quedado el bug del color en el ::Say y en el ::sayRotate
En el methodo Rect() falta hacer HPDF_Page_Stroke ( ::hPage )
En RoundBox() el calculo del nRay no es correcto , se van los angulos , yo creo que tendria que ser asi aunque no es seguro del todo .

nRay = Round( iif( ::nWidth > ::nHeight, Min( nRound,Int( (nBottom - nTop ) / 2 ) ), Min( nRound,Int( (nRight - nLeft) / 2 ) ) ), 0 )

Un saludo.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 80 guests