ayuda en pdf

ayuda en pdf

Postby surGom » Tue Jun 17, 2014 11:06 pm

Estuve tratando de usar la clase harupdf y realmente no la pude hacer funcionar en el ejemplo de testprn6, quise hacer que me haga una sola página con solo una línea y tampoco .

Necesito poder usar la clase tpdf (es lo único que me falta para poder utilizar harbour en vez de xharbour) ya que la utilizo para enviar por correo las cuentas corrientes de clientes y proveedores, así como las retenciones que le hacemos a los mismos.

Bueno la consulta poder hacer legible este código(clase tpdf) que en xharbour se compila bien


Code: Select all  Expand view
#pragma begindump
926-   int Bin2i( BYTE * pszString )
927-   {
928-
929-   ULONG ulLen = strlen( pszString ) ;
930-                         int i = HB_MKSHORT( ( ulLen >= 1 ) ? ( BYTE ) pszString[ 0 ]:0,
931-   ( ulLen >= 2 ) ? ( BYTE ) pszString[ 1 ] :0 ) ;
932-     //int i;
933-   //    i = *((short *) pszString);
931-   return i ;
935-    }

 const char szFontTable[ ] = {
   "\xfa\0\xfa\0\xfa\0\xfa\0\x4d\x01\x4d\x01\x4d\x01\x85\x01"
   "\x98\x01\x2b\x02\xa4\x01\x2b\x02\xf4\x01\xf4\x01\xf4\x01\xf4\x01"
   "\xf4\x01\xf4\x01\xf4\x01\xf4\x01\x41\x03\xe8\x03\x41\x03\x41\x03"
   "\x0a\x03\x41\x03\x0a\x0,,,,,,,, etc etc


los errores al compilar con harbour

Code: Select all  Expand view


[code]Compilando PDFHBDCS.PRG...
Error E2147 PDFHBDCS.PRG 926: 'BYTE' cannot start a parameter declaration
Error E2451 PDFHBDCS.PRG 929: Undefined symbol 'ULONG' in function Bin2i
Error E2379 PDFHBDCS.PRG 929: Statement missing ; in function Bin2i
Error E2140 PDFHBDCS.PRG 930: Declaration is not allowed here in function Bin2i
Error E2451 PDFHBDCS.PRG 931: Undefined symbol 'ulLen' in function Bin2i
Error E2256 PDFHBDCS.PRG 931: No : following the ? in function Bin2i
Warning W8057 PDFHBDCS.PRG 935: Parameter 'pszString' is never used in function Bin2i

 


Si esto se puede solucionar luego les consultare sobre otros items que estan compilados en PDFHBDCS.c

Disculpen la molestia

Luis
surGom
 
Posts: 639
Joined: Wed Oct 19, 2005 12:03 pm

Re: ayuda en pdf

Postby Antonio Linares » Wed Jun 18, 2014 7:25 am

Luis,

Usa esto:

#define BYTE unsigned char

#define ULONG unsigned long

ó sencillamente reemplázalos por esas definiciones
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41403
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ayuda en pdf

Postby surGom » Wed Jun 18, 2014 11:11 pm

Gracias Antonio con esos defines solucione los problemas del programa pdfhbdoc.prg. Aparecen varios warning pero creo que no van a afectar

En pdfhbdoc.c aparecieron algo así como 48 errores y buscando por internet encontré una página de como migrar de xHarbour a Harbour y pude reducir a 10 problemas de los cuales la mayoría es el mismo error. Bueno si me pueden ayudar con estos errores ya que estuve buscando pero no lo puedo resolver y quizas puedan ayudarme.

EL error mayoritario es

(1)Error E2294 pdfhbdoc.c 293: Structure required on left side of . or .* in function HB_FUN_HB_PDFINITBOOK

Code: Select all  Expand view
 
291-if ( !bInitArray )
292-   {
293-      pArray.type = HB_IT_NIL;
294-      hb_arrayNew( &pArray, 0 );
295-      bInitArray = 1;
   }


En el siguiente trozo de código, las sentencias dan error (1)
Code: Select all  Expand view
 
305-   Temp.type=HB_IT_NIL;
306-     TempArray.type=HB_IT_NIL;

etc etc
327-  TempArray.type = HB_IT_NIL;                  
etc etc

398-  TempArray.type = HB_IT_NIL;
399-  TempArray1.type = HB_IT_NIL;

415- TempArray2.type = HB_IT_NIL;

498-         TempArray3.type = HB_IT_NIL;
499-         TempArray2.type = HB_IT_NIL;


perdón por ser reiterativo pero quería mostrar que siempre es el mismo error Structure required on left side of . or .* in fuction
y el diferente pero debe estar referido al error de la línea 327

Error E2227 pdfhbdoc.c 328: Extra parameter in call to hb_arrayScan in function HB_FUN_HB_PDFBOOKMARK


Code: Select all  Expand view
  328- uiPos = hb_arrayScan( &pArray, pBlock, NULL, NULL, 0, 0 );


Gracias por su paciencia

Luis
surGom
 
Posts: 639
Joined: Wed Oct 19, 2005 12:03 pm

Re: ayuda en pdf

Postby surGom » Wed Jun 18, 2014 11:55 pm

Compañeros bueno seguí intentando y no sé si esta bien, pero lo que hice con la mayoría de los errores
sacarle el punto y lo que estaba a la derecha

pArray.temp lo deje pArray y así todos los similares

y ahora me quedo 1 solo error que es

Error E2227 pdfhbdoc.c 328: Extra parameter in call to hb_arrayScan in function HB_FUN_HB_PDFBOOKMARK


Code: Select all  Expand view

   328- uiPos = hb_arrayScan( &pArray, pBlock, NULL, NULL, 0, 0 );
 



Voy a ver si lo puedo encontrar pero si alguien sabe como resolverlo agradecido

Luis
surGom
 
Posts: 639
Joined: Wed Oct 19, 2005 12:03 pm

Re: ayuda en pdf

Postby Antonio Linares » Thu Jun 19, 2014 8:37 am

Luis,

> sacarle el punto y lo que estaba a la derecha

Esa no es la solución correcta.

Cambia el "." por "->" pero no borres lo de la derecha.

Prueba por favor con esto y confírmame que te queda para ayudarte
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41403
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ayuda en pdf

Postby Antonio Linares » Thu Jun 19, 2014 8:39 am

Esta es la declaración de hb_arrayScan:

HB_SIZE hb_arrayScan( PHB_ITEM pArray, PHB_ITEM pValue, HB_SIZE * pnStart, HB_SIZE * pnCount, HB_BOOL fExact )

Modifica así tu código:

uiPos = hb_arrayScan( &pArray, pBlock, NULL, NULL, HB_FALSE );
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41403
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ayuda en pdf

Postby Antonio Linares » Thu Jun 19, 2014 8:41 am

Luis,

encontré una página de como migrar de xHarbour a Harbour


Si no es el documento official que proporciona Harbour:

https://github.com/harbour/core/blob/master/doc/xhb-diff.txt

Por favor índicame cual es (en tu historial del navegador debe estar) para que así la tengamos disponible para todos, gracias :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41403
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ayuda en pdf

Postby hmpaquito » Thu Jun 19, 2014 9:45 am

Hombre Antonio, unos xantiguos compañeros sacaron un docu :roll: al respecto del tema de que estamos trayendo a colación, cuando transicionaron, y hablando de transiciones :P esta mañana ha sido entronizado Felipe VI como rey de todos los españoles. Viva el rey ! Viva España ! :wink:
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: ayuda en pdf

Postby surGom » Thu Jun 19, 2014 12:53 pm

Antonio había probado de cambiar

Temp.type=HB_IT_NIL;
por
Temp->type=HB_IT_NIL;
pero me seguía dando los mismos errores así que los deje de esta forma

Temp=HB_IT_NIL;

leí tu comentario esta mañana temprano (en mi casa, miren lo ansioso que estaba) pero los deje como estaba e hice la modificación que me comentaste

Code: Select all  Expand view

uiPos = hb_arrayScan( &pArray, pBlock, NULL, NULL, HB_FALSE );
 


lo compilé y voilá funcionó, me creo tpdf.lib

Lo enlace con el programa con pocas esperanzas debido al ->, pero FUNCIONÓ. Estaba tan contento que hice el postreply desde casa comentando que cuando llegara a la oficina iba a probarlo mas tranquilo y si realmente funcionaba bien les iba a dejar un enlace con el zip y la librería enlazada en harbour 3.2, pero de distraído me olvide de dar el save.
Así que ahora se los envío y también les dejo el prg con el cual crea el archivo que les envío, para que vean lo simple y lo pequeño que es el pdf creado. Según comentarios anteriores es muy limitada la clase en lo que se refiere a la font pero creo que es muy útil.


https://drive.google.com/file/d/0B8UT40 ... sp=sharing


Muchísimas gracias Antonio por tu ayuda, sin ella estaría en un callejón sin salida porque el último cambio que tu me enviaste, estuve anoche buscando por todos lados y no lo pude encontrar.

Nuevamente Gracias

Luis
surGom
 
Posts: 639
Joined: Wed Oct 19, 2005 12:03 pm

Re: ayuda en pdf

Postby surGom » Thu Jun 19, 2014 12:57 pm

La migracion de xharbour a harbour la encontré en

www.-.com/dokuwiki/doku.php?id=mig ... .a.harbour

pero si buscan migrar de harbour a xharbour en google van encontrar un montón de enlaces

Luis
surGom
 
Posts: 639
Joined: Wed Oct 19, 2005 12:03 pm

Re: ayuda en pdf

Postby Manuel Valdenebro » Thu Jun 19, 2014 3:30 pm

Luis,

¿Se trata realmente de la librería Harupdf?. Yo tengo el código antiguo de esa clase Harupdf y es distinto al que tu envias. Aparece registrada a nombre de Andij Ahja y Pritpal Bedi. En cambio, el código que tu usas creo que es de la libreria tpdf de Luiz Culik.

¿Son la misma librería? ¿o realmente tu estás usando la tpdf y no la Harupdf?
Un saludo

Manuel
User avatar
Manuel Valdenebro
 
Posts: 706
Joined: Thu Oct 06, 2005 9:57 pm
Location: Málaga-España

Re: ayuda en pdf

Postby surGom » Thu Jun 19, 2014 3:52 pm

No Manuel es la clase tpdf, y funciona en harbour

Luis
surGom
 
Posts: 639
Joined: Wed Oct 19, 2005 12:03 pm

Re: ayuda en pdf

Postby Antonio Linares » Thu Jun 19, 2014 5:15 pm

Luis,

Me alegro de que esté ya funcionando bien :-)

Podrias publicar el código en C para ver como ha quedado ? gracias
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41403
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ayuda en pdf

Postby surGom » Thu Jun 19, 2014 6:01 pm

Antonio el código y todas las fuentes estan para descargar desde el enlace que publique

El archivo es este
Code: Select all  Expand view

*
 * $Id: pdfhbdoc.c,v 1.2 2005/04/23 06:52:17 guerra000 Exp $
 */

/*
 * Harbour Project source code:
 * PDF low level Api for HBDOC
 *
 * Copyright 2000-2004 Luiz Rafael Culik <culikr /at/ brturbo.com>
 * www - http://www.harbour-project.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
 *
 * As a special exception, the Harbour Project gives permission for
 * additional uses of the text contained in its release of Harbour.
 *
 * The exception is that, if you link the Harbour libraries with other
 * files to produce an executable, this does not by itself cause the
 * resulting executable to be covered by the GNU General Public License.
 * Your use of that executable is in no way restricted on account of
 * linking the Harbour library code into it.
 *
 * This exception does not however invalidate any other reasons why
 * the executable file might be covered by the GNU General Public License.
 *
 * This exception applies only to the code released by the Harbour
 * Project under the name Harbour.  If you copy code from other
 * Harbour Project or Free Software Foundation releases into a copy of
 * Harbour, as the General Public License permits, the exception does
 * not apply to the code that you add in this way.  To avoid misleading
 * anyone as to the status of such modified files, you must delete
 * this exception notice from them.
 *
 * If you write modifications of your own for Harbour, it is your choice
 * whether to permit this exception to apply to your modifications.
 * If you do not wish that, delete this exception notice.
 *
 */



#include <hbapi.h>
#include <hbapiitm.h>
#include "pdflib.h"

PDF *szPDFFile;
#define FONTBOLD "Courier-Bold"
#define FONTNORMAL "Courier"
#define FONTSIZE 10.0/*10.0*/
#define FONTSIZEBOLD 15.0
#define FONTSIZESMALL 10.0     /*10.0*/
#define FONTSIZETABLE 8.5
#define LEAD ((int) (FONTSIZESMALL * 1.0))
#define LEADLINK ((int) (FONTSIZESMALL * 1.3))
#define LEADTABLE ((int) (FONTSIZESMALL * 1.2))

static float fRow = 800;
static float fOldPos;
static float iWidth;
static float fCol;
static int sziFontBold = 0;
static int sziFont = 0;
static int iPage = 1;
static float fCurRow, fCurCol = 0 ,fCurLastCol, fLastRow;
static float fStartCol, fStartCol2;
static PHB_ITEM pArray = { 0 };
static HB_BOOL bInitArray = 0;
static float hb_checkStringWidth( const char * szString );
static float hb_pdfGetHeight( const char *szText );
static void hb_ProcessTableItem( PHB_ITEM p1, PHB_ITEM p2, PHB_ITEM p3, PHB_ITEM p4 );
static HB_ULONG uiLen;
static HB_ULONG uiCount;
static HB_BOOL bTItems;
static HB_BOOL bFItems;
float getText( PDF *p, const char *szText, int iFont, float frow, float fcol, float iw);
void  setText( PDF *p, const char *szText, float frow, float fcol, float h, float iw);

HB_FUNC(HB_PDFNEW)
{
   const char *szFileResult;
   szFileResult= ( char * ) hb_parc( 1 );

   if ( szPDFFile == NULL)
   {
      szPDFFile = PDF_new();
      PDF_set_value( szPDFFile, "compress", ( float ) 9);
   }

   if ( PDF_open_file( szPDFFile, szFileResult ) == -1 )
   {
     hb_retl( 1 );
   }

   PDF_set_info( szPDFFile, "Keywords", "XHarbour compiler" );
   PDF_set_info( szPDFFile, "Subject" , "XHarbour" ) ;
   PDF_set_info( szPDFFile, "Title"   , "XHarbour doc guide" );
   PDF_set_info( szPDFFile, "Creator" , "HBDOC XHarbour Document Extractor" );
   PDF_set_info( szPDFFile, "Author"  , "Luiz Rafael Culik" );
   sziFont = PDF_findfont( szPDFFile, FONTNORMAL, "host", 0);
   sziFontBold = PDF_findfont( szPDFFile, FONTBOLD, "host", 0);
   hb_retl( 0 );
}

HB_FUNC(HB_PDFNEWPAGE)
{
   const char *szTitleT;
   fCurCol = 0;
   szTitleT= ( char * ) hb_parc( 1 );
   PDF_begin_page( szPDFFile, a4_width, a4_height ); /* start a new page */
   PDF_setfont( szPDFFile, sziFontBold, FONTSIZEBOLD );
   PDF_show_xy( szPDFFile, szTitleT, 50, fRow -= LEAD );
}

HB_FUNC(HB_PDFENDPAGE)
{
   fRow = 800;
   PDF_end_page( szPDFFile );                /* close page       */
   iPage ++ ;
}

HB_FUNC(HB_PDFWRITEBOLDTEXT)
{
   const char *szTextT;
   szTextT = ( char * ) hb_parc( 1 );

   if ( fRow<=40)
   {
      fRow=800;
      PDF_end_page( szPDFFile );
      sziFont = PDF_findfont( szPDFFile, FONTNORMAL, "host", 0 );
      sziFontBold = PDF_findfont( szPDFFile, FONTBOLD, "host", 0 );
      PDF_begin_page( szPDFFile, a4_width, a4_height ); /* start a new page */
      iPage ++ ;
   }

   PDF_setfont( szPDFFile, sziFontBold, FONTSIZESMALL );

   PDF_show_xy( szPDFFile, szTextT, 25, fRow -= LEAD );
   PDF_setfont( szPDFFile, sziFont, FONTSIZESMALL );
}

HB_FUNC(HB_PDFWRITEBOLDTEXT1)
{
   const char *szTextT;
   szTextT = ( char * ) hb_parc( 1 );

   if ( fRow <= 40 )
   {
      fRow = 800;
      PDF_end_page( szPDFFile );
      PDF_begin_page( szPDFFile, a4_width, a4_height ); /* start a new page */
      sziFont = PDF_findfont( szPDFFile, FONTNORMAL, "host", 0);
      sziFontBold = PDF_findfont( szPDFFile, FONTBOLD, "host", 0);
      iPage ++;
   }

   PDF_setfont( szPDFFile, sziFontBold, FONTSIZEBOLD );
   PDF_show_xy( szPDFFile, szTextT, 25, fRow -= LEAD );
   PDF_setfont( szPDFFile, sziFont, FONTSIZESMALL );
}

HB_FUNC(HB_PDFWRITETEXT)
{
   const char *szTextT;
   szTextT = ( char * ) hb_parc( 1 );

   if ( fRow <= 40 )
   {
      fRow=800;
      PDF_end_page( szPDFFile );
      sziFont = PDF_findfont( szPDFFile, FONTNORMAL, "host", 0);
      sziFontBold = PDF_findfont( szPDFFile, FONTBOLD, "host", 0);
      PDF_begin_page( szPDFFile, a4_width, a4_height); /* start a new page */
      iPage ++;
   }

   PDF_setfont( szPDFFile, sziFont, FONTSIZESMALL );
   PDF_show_xy( szPDFFile, szTextT, 25, fRow -= LEAD);
}

HB_FUNC(HB_PDFCLOSE)
{
   hb_itemClear( &pArray );
   PDF_close( szPDFFile );               /* close PDF document   */
   PDF_delete( szPDFFile );             /* delete the PDF object */
   szPDFFile=NULL;
   sziFontBold=NULL;
   sziFont=NULL;
}

HB_FUNC(HB_PDFWRITEARG)
{
   const char *szTextT;
   const char *szBTextT;

   szTextT  = ( char * ) hb_parc( 2 );
   szBTextT = ( char * ) hb_parc( 1 );

   if ( fRow <= 40 )
   {
      fRow = 800;
      PDF_end_page( szPDFFile );
      sziFont = PDF_findfont( szPDFFile, FONTNORMAL, "host", 0);
      sziFontBold = PDF_findfont( szPDFFile, FONTBOLD, "host", 0);
      PDF_begin_page( szPDFFile, a4_width, a4_height); /* start a new page */
      iPage ++;
   }

   PDF_setfont( szPDFFile, sziFontBold, FONTSIZESMALL );
   PDF_show_xy( szPDFFile, szBTextT, 25, fRow -= LEAD );
   PDF_setfont( szPDFFile, sziFont, FONTSIZESMALL );
   PDF_show( szPDFFile, szTextT );
}

HB_FUNC(HB_PDFADDLINK)
{
   int iPagetoGo = hb_parni( 2 ) - 1;
   const char *szLink;

   szLink = ( char * ) hb_parc( 1 );
   if (fRow <= 40 )
   {
      fRow = 800;
      PDF_end_page( szPDFFile );
      sziFont = PDF_findfont( szPDFFile, FONTNORMAL, "host", 0 );
      sziFontBold = PDF_findfont( szPDFFile, FONTBOLD, "host", 0 );
      PDF_begin_page( szPDFFile, a4_width, a4_height ); /* start a new page */
      PDF_setfont( szPDFFile, sziFont, FONTSIZESMALL );
      iPage ++;
   }

   fCol   = ( float ) fRow;
   iWidth = hb_checkStringWidth( szLink );

   // New Page,  so curCol is 0
   if ( fCurCol == 0)
   {
      fCurCol = 60 ;
      fLastRow = ( fRow - LEADLINK );
      fCurLastCol = ( fCol - LEAD );
      fStartCol = 49 ;
      fStartCol2 = 50 ;

   }

   if ( fCurCol + iWidth + 10  <= a4_width )
   {
      PDF_set_border_color( szPDFFile, ( float ) 1 ,( float )  1 ,( float ) 1 );
      PDF_add_locallink( szPDFFile, fStartCol, fLastRow, fCurCol + iWidth, fCol, iPagetoGo, "fitwidth");
      PDF_setrgbcolor( szPDFFile, ( float ) 0, ( float ) 0, ( float ) 1 );
      PDF_set_parameter( szPDFFile, "underline", "true" );
      PDF_show_xy( szPDFFile, szLink, fStartCol2, fCurLastCol );
      PDF_setrgbcolor( szPDFFile, ( float ) 0, ( float ) 0, ( float ) 0);
      PDF_set_parameter( szPDFFile, "underline", "false");
      fCurCol += 10 + iWidth;
      fStartCol +=  iWidth;
      fStartCol2 += iWidth;


      if( fCurCol > a4_width )
      {
          fCurCol = 00 ;
          fStartCol = 49 ;
          fStartCol2 = 50 ;
          fRow -= LEADLINK;
          fCol -= LEAD;

      }
    }
      iWidth = 0 ;
}

HB_FUNC(HB_PDFINITBOOK)
{
   PHB_ITEM pItems;
   pItems = hb_param( 1, HB_IT_ARRAY );
   uiLen = hb_arrayLen( pItems );

   if ( !bInitArray )
   {
      pArray  = HB_IT_NIL;
      hb_arrayNew( &pArray, 0 );
      bInitArray = 1;
   }

   for ( uiCount = 1 ; uiCount <= uiLen ; uiCount++ )
   {
      const char *szBook = ( char * ) hb_arrayGetCPtr( pItems, uiCount );
      int iLevel;
      PHB_ITEM TempArray;
      PHB_ITEM Temp;

      Temp =HB_IT_NIL;
      TempArray =HB_IT_NIL;

      hb_arrayNew( &TempArray, 2 );
      iLevel=PDF_add_bookmark( szPDFFile, szBook, 0, 0);
      hb_arraySetForward( &TempArray, 1, hb_itemPutC( &Temp, hb_arrayGetCPtr( pItems, uiCount ) ) );

      hb_arraySetForward( &TempArray, 2, hb_itemPutNI( &Temp, iLevel));
      hb_arraySetForward( &pArray, uiCount, &TempArray );
      hb_itemClear( &Temp ) ;

   }
}

HB_FUNC(HB_PDFBOOKMARK)
{
   const char *szBook1 =( char * )hb_parc( 2 );
   HB_ULONG uiPos;
   PHB_ITEM TempArray;
   int iParent = 0;
   PHB_ITEM pBlock = hb_param( 3, HB_IT_BLOCK );

   TempArray  = HB_IT_NIL;
   //uiPos = hb_arrayScan( &pArray, pBlock, NULL, NULL, 0, 0 );
   uiPos = hb_arrayScan( &pArray, pBlock, NULL, NULL, HB_FALSE );

   if ( uiPos > 0 )
   {
      if ( hb_arrayGet( &pArray, uiPos, &TempArray ) )
      {
         iParent = hb_arrayGetNI( &TempArray, 2      );
         hb_itemClear( &TempArray );
      }
   }

   PDF_add_bookmark(szPDFFile, szBook1, iParent, 0);
}

HB_FUNC(HB_GETPAGE)
{
   hb_retni( iPage );
}

static  HB_BOOL hb_checkRow( float iLine )
{
   if ( iLine <= 20 )
   {
      fRow = 800;
      PDF_end_page( szPDFFile );
      PDF_begin_page( szPDFFile, a4_width, a4_height); /* start a new page */
      iPage ++;
      return HB_TRUE ;
   }

   return HB_FALSE;
}

static  float hb_checkStringWidth(const char *szString)
{
   float fReturn;
   fReturn = PDF_stringwidth( szPDFFile, szString, sziFont, FONTSIZESMALL);
   return fReturn;
}

HB_FUNC(HB_PDFTABLE)
{
   PHB_ITEM pTableItem  ;
   PHB_ITEM pTableItem1 ;
   PHB_ITEM pTableItem2 ;
   PHB_ITEM pTableItem3 ;
   HB_ULONG ulPos;

   pTableItem  = hb_param( 1, HB_IT_ARRAY );
   pTableItem1 = hb_param( 2, HB_IT_ARRAY );
   pTableItem2 = hb_param( 3, HB_IT_ARRAY );
   pTableItem3 = hb_param( 4, HB_IT_ARRAY );

   if ( pTableItem2 != NULL)
   {
      bTItems = HB_TRUE;
   }

   if ( pTableItem3 != NULL )
   {
      bFItems = HB_TRUE;
      bTItems = HB_FALSE;
   }

   fRow -= LEAD;

   for ( ulPos = 1 ; ulPos <= hb_arrayLen( pTableItem ) ; ulPos ++ )
   {
      PHB_ITEM TempArray  ;
     PHB_ITEM TempArray1 ;
      TempArray  = HB_IT_NIL;
      TempArray1  = HB_IT_NIL;

      fCol = fRow;
      hb_arrayGet( pTableItem, ulPos, &TempArray);
      hb_arrayGet( pTableItem1, ulPos, &TempArray1 );

      if ( !bTItems && !bFItems)
      {
         hb_ProcessTableItem( &TempArray, &TempArray1, NULL, NULL);
         hb_itemClear( &TempArray );
         hb_itemClear( &TempArray1 );
      }

      if ( bTItems && !bFItems)
      {
        PHB_ITEM TempArray2;
         TempArray2  = HB_IT_NIL;

         hb_arrayGet( pTableItem2 , ulPos, &TempArray2 );
         hb_ProcessTableItem( &TempArray, &TempArray1, &TempArray2, NULL );
         hb_itemClear( &TempArray );
         hb_itemClear( &TempArray1 );
         hb_itemClear( &TempArray2 );
      }

      if (!bTItems && bFItems)
      {
        PHB_ITEM TempArray2 ;
        PHB_ITEM TempArray3 ;

         TempArray3  = HB_IT_NIL;
         TempArray2  = HB_IT_NIL;

         hb_arrayGet( pTableItem2, ulPos, &TempArray2 );
         hb_arrayGet( pTableItem3, ulPos, &TempArray3 );
         hb_ProcessTableItem( &TempArray, &TempArray1, &TempArray2, &TempArray3 );
         hb_itemClear( &TempArray );
         hb_itemClear( &TempArray1 );
         hb_itemClear( &TempArray2 );
         hb_itemClear( &TempArray3 );
     }
   }

   bTItems=HB_FALSE;
   bFItems=HB_FALSE;
   fOldPos=0;
}

static void hb_ProcessTableItem( PHB_ITEM p1, PHB_ITEM p2, PHB_ITEM p3, PHB_ITEM p4)
{
   HB_ULONG ulTempPos;
   HB_ULONG ulLen;
   float fHeight;
   float fI;
   float iitem, iitem1, iitem2,iitem3;

   ulLen = hb_arrayLen( p1 );

   for ( ulTempPos = 1 ; ulTempPos <= ulLen ; ulTempPos ++ )
   {
      const char *szTemp  = ( char * ) hb_arrayGetCPtr( p1, ulTempPos );
      const char *szTemp1 = ( char * ) hb_arrayGetCPtr( p2, ulTempPos );

      if (!bTItems && !bFItems)
      {
         PDF_setfont( szPDFFile, sziFont, FONTSIZETABLE);
         iitem  = getText( szPDFFile, szTemp1, sziFont, 293, fRow, 261);
         iitem1 = getText( szPDFFile, szTemp, sziFont, 27, fRow, 261);
         if ( iitem < iitem1)
         {
            setText( szPDFFile, szTemp1, 293, fRow, iitem1, 261);
            setText( szPDFFile, szTemp, 27, fRow, iitem1, 261);
            fRow -= iitem1;
         }
         else
         {
            setText( szPDFFile, szTemp1, 293, fRow, iitem, 261);
            setText( szPDFFile, szTemp, 27, fRow, iitem, 261);
            fRow -= iitem;
         }

      }

      if (bTItems && !bFItems)
      {
         const char * szTemp2=( char * ) hb_arrayGetCPtr( p3, ulTempPos );

         PDF_setfont( szPDFFile, sziFont, FONTSIZETABLE);
         iitem  = getText( szPDFFile, szTemp2, sziFont, 381, fRow, 173);
         iitem1 = getText( szPDFFile, szTemp1, sziFont, 204, fRow, 172);
         iitem2 = getText( szPDFFile, szTemp,  sziFont, 27,  fRow, 172);

         if ( iitem > iitem1 && iitem > iitem2)
         {
            setText( szPDFFile, szTemp2, 381, fRow, iitem, 173);
            setText( szPDFFile, szTemp1, 204, fRow, iitem, 172);
            setText( szPDFFile, szTemp , 27,  fRow, iitem, 172);
            fRow -= iitem;
         }

         if ( iitem2 > iitem && iitem2 >iitem1)
         {
            setText( szPDFFile, szTemp2, 381, fRow, iitem2, 173);
            setText( szPDFFile, szTemp1, 204, fRow, iitem2, 172);
            setText( szPDFFile, szTemp,  27,  fRow, iitem2, 172);
            fRow -= iitem2;
         }

         if ( iitem1 > iitem && iitem1 > iitem2 )
         {
            setText( szPDFFile, szTemp2, 381, fRow, iitem1, 173);
            setText( szPDFFile, szTemp1, 204, fRow, iitem1, 172);
            setText( szPDFFile, szTemp,  27,  fRow, iitem1, 172);
            fRow -= iitem1;
         }

      }

      if ( !bTItems && bFItems )
      {
         const char * szTemp2 = ( char * ) hb_arrayGetCPtr( p3, ulTempPos );
         const char * szTemp3 = ( char * ) hb_arrayGetCPtr( p4, ulTempPos );

         PDF_setfont( szPDFFile, sziFont, FONTSIZETABLE);
         iitem1 = getText( szPDFFile, szTemp3, sziFont, 426, fRow, 128 );
         iitem2 = getText( szPDFFile, szTemp2, sziFont, 293, fRow, 128 );
         iitem  = getText( szPDFFile, szTemp1, sziFont, 160, fRow, 128 );
         iitem3 = getText( szPDFFile, szTemp, sziFont,  27,  fRow, 128 );
         if (iitem > iitem1 && iitem > iitem2 && iitem > iitem3)
         {
            setText( szPDFFile, szTemp3, 426, fRow, iitem, 128);
            setText( szPDFFile, szTemp2, 293, fRow, iitem, 128);
            setText( szPDFFile, szTemp1, 160, fRow, iitem, 128);
            setText( szPDFFile, szTemp,  27,  fRow, iitem, 128);
            fRow -= iitem;
         }
         else
         {
            if (iitem2 > iitem && iitem2 > iitem1 && iitem2 > iitem3)
            {
               setText( szPDFFile, szTemp3, 426, fRow, iitem2, 128);
               setText( szPDFFile, szTemp2, 293, fRow, iitem2, 128);
               setText( szPDFFile, szTemp1, 160, fRow, iitem2, 128);
               setText( szPDFFile, szTemp,   27, fRow, iitem2, 128);
               fRow -= iitem2;
            }
            else
            {
               if ( iitem1 > iitem && iitem1 > iitem2 && iitem1 > iitem3)
               {
                   setText(  szPDFFile, szTemp3, 426, fRow, iitem1, 128);
                   setText(  szPDFFile, szTemp2, 293, fRow, iitem1, 128);
                   setText(  szPDFFile, szTemp1, 160, fRow, iitem1, 128);
                   setText(  szPDFFile, szTemp,   27, fRow, iitem1, 128);
                   fRow -= iitem1;
               }
               else
               {
                  if ( iitem3 > iitem && iitem3 > iitem2 && iitem3 > iitem)
                  {
                     setText( szPDFFile, szTemp3, 426, fRow, iitem3, 128);
                     setText( szPDFFile, szTemp2, 293, fRow, iitem3, 128);
                     setText( szPDFFile, szTemp1, 160, fRow, iitem3, 128);
                     setText( szPDFFile, szTemp,   27, fRow, iitem3, 128);
                     fRow -= iitem3;
                  }
                  else
                  {
                     setText( szPDFFile, szTemp3, 426, fRow, iitem3, 128);
                     setText( szPDFFile, szTemp2, 293, fRow, iitem3, 128);
                     setText( szPDFFile, szTemp1, 160, fRow, iitem3, 128);
                     setText( szPDFFile, szTemp,   27, fRow, iitem3, 128);
                     fRow -= iitem3;

                  }
               }
            }
         }
      }
   }
}

float getText( PDF *p, const char *szText, int iFont, float frow, float fcol, float iw )
{
     float h;
     float w;
     int c;
     h = FONTSIZETABLE * 2;
     PDF_setfont( p, iFont, 7.0);

     c = PDF_show_boxed( p, szText, frow, fcol, iw, h, "justify", "blind" );

     while ( c > 0)
     {
        h += FONTSIZETABLE;
        c = PDF_show_boxed(p, szText, frow, fcol, iw, h, "justify", "blind" );
     }

     return h;
}

void setText( PDF *p, const char *szText, float frow, float fcol, float h, float iw )
{
     PDF_show_boxed( p, szText, frow, fcol, iw, h, "justify", "" );
     PDF_rect( p, frow, fcol, iw + 5, h );
     PDF_stroke( p );
}
 


Luis
surGom
 
Posts: 639
Joined: Wed Oct 19, 2005 12:03 pm

Re: ayuda en pdf

Postby Antonio Linares » Fri Jun 20, 2014 5:33 am

Luis,

Las líneas en donde haces:

Temp =HB_IT_NIL;
TempArray =HB_IT_NIL;

en realidad no hacen nada, y funciona porque es el equivalente de hacer esto, que es lo correcto:

PHB_ITEM Temp = NULL;
PHB_ITEM TempArray = NULL;

Prueba a hacer estos cambios y tu código estará correcto. Como te digo, el otro funciona de causalidad porque HB_IT_NIL vale lo mismo que NULL. Pero estas asignando un valor de tipo Harbour a un puntero, lo cual no es correcto. Te funciona porque el resultado es el mismo, pero tecnicamente es incorrecto y en el futuro puede ser una potencial fuente de errores (si por la razón que fuese se cambiasen esas definiciones en Harbour).
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41403
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 58 guests