FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour THaruPdf Mastintin Edition
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
THaruPdf Mastintin Edition
Posted: 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 (fw): Select all Collapse
#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
鈥淚f you think education is expensive, try ignorance"
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: THaruPdf Mastintin Edition
Posted: Wed Feb 22, 2017 02: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
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: THaruPdf Mastintin Edition
Posted: Wed Feb 22, 2017 05:32 PM
Gracias por lo de Mastintin Edition ... :-)

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 (fw): Select all Collapse
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.
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: THaruPdf Mastintin Edition
Posted: Thu Feb 23, 2017 09: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
鈥淚f you think education is expensive, try ignorance"
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: THaruPdf Mastintin Edition
Posted: Thu Feb 23, 2017 09:30 AM
mastintin wrote:Gracias por lo de Mastintin Edition ... :-)

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 (fw): Select all Collapse
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
鈥淚f you think education is expensive, try ignorance"
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: THaruPdf Mastintin Edition
Posted: Thu Feb 23, 2017 06: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 (fw): Select all Collapse
聽 聽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 (fw): Select all Collapse
聽 聽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()
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: THaruPdf Mastintin Edition
Posted: Fri Feb 24, 2017 11:57 AM
creo que he localizado otro bug . Estye esta en Saybitmap ...

Code (fw): Select all Collapse
      /* 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 .
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: THaruPdf Mastintin Edition
Posted: 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
鈥淚f you think education is expensive, try ignorance"
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: THaruPdf Mastintin Edition
Posted: Mon Feb 27, 2017 08: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 &gt; ::nHeight, Min( nRound,Int( (nBottom - nTop ) / 2 ) ), Min( nRound,Int( (nRight - nLeft) / 2 ) ) ), 0 )

Un saludo.

Continue the discussion