FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour preview to pdf using image2pdf
Posts: 31
Joined: Sun Jan 29, 2006 06:34 PM
preview to pdf using image2pdf
Posted: Tue Apr 15, 2008 06:06 PM

Hi

Can anyone has modified rpreview.prg to capture emf files and send them to IMAGE2PDF .

I need to create a PDF from Preview and automatically gives it a path and Name

Best regards

Posts: 383
Joined: Tue Oct 11, 2005 01:01 PM
preview to pdf using image2pdf
Posted: Wed Apr 16, 2008 10:10 AM
Try this...


           DEFINE BUTTON RESOURCE "ACROBAT" OF oBar GROUP ;
              MESSAGE "Crea PDF"                 ;
              ACTION  SavePDF( ::oDevice ) ;
              TOOLTIP "Crea PDF"


...
...


 Function SavePdf( oDevice, lEmail )

 LOCAL imageFilename := "   "
 LOCAL ix
 LOCAL iErr := 0
 LOCAL error
 LOCAL i, hLibImg2PDF
 local cPdffilename := oV:arc_dir + "TEMP\" + "WP"+DTOS(DATE())+"-"+STRTRAN( TIME(), ":", "" ) + "_" + ov:work_st + ".pdf" // "Test.pdf"
 local aFiles:={}
 LOCAL oMail, oFontT, cMailText

 DEFAULT lEmail := .F.

 IF !FILE( "image2PDF.dll" )
  msgStop("MANCA FILE CREAZIONE PDF", APP_NAME )
  RETURN NIL
 ENDIF 

 aFiles := oDevice:aMeta

  IF LEN( aFiles ) = 0
    RETURN NIL
  ENDIF

 hLibImg2PDF:=LoadLib32( "image2PDF.dll")

   if ValType( aFiles ) == "A"

      //IF lAnd( WP_GEST_PDF, oV:nModuloWP )
        //I2PDF_License("xxxxxxxxxxxxxxx")
      //ELSE
        I2PDF_License("DEMO")
      //ENDIF

      iErr := IPMeta( )      // Flag that his is a meta file
      iErr := IPSize( )      // Reset the size
      iErr := IPMetaAdjustText()

      IF !lAnd( WP_GEST_PDF, oV:nModuloWP )
        xI2PDF_BatesFormat( "Microsystem - VERSIONE DIMOSTRATIVA" )
        xI2PDF_BatesLocation( 2, 2, 0 )
        xI2PDF_BatesFont_Int( 30, "Times-Roman", 30, 60, 90, 1, 40, 50, 60 )
        xI2PDF_BatesBackground_Int( 1, 192, 192, 192 )
      ENDIF

      // here, first convert the first image.
      iErr := IPSetDPI(0)   // Set DPI to the default for PDF's.  It works better.
      

      FOR ix := 1 TO LEN( aFiles )   // Build the pages using the array of temp files
         imageFilename := aFiles[ix]
         iErr := IPAddImg(imageFilename)
      NEXT

better.
      iErr := IPMakePDF(cPdffilename, 0, error, 40 )   // Create the PDF.
   ENDIF

   FreeLib32( hLibImg2PDF )

   IF !EMPTY( oFontT )
     oFontT:end()
   ENDIF

   if ! file(cPdfFileName)
      Msginfo("Errore nella creazione del file PDF")
      return nil
   Endif

  IF !lEmail
    ShellExecute( ,"open",cPdfFileName,"",".\",.t. )
  ELSE

      cMailText := MEMOREAD( "testomail.txt" )
      cMailText := IIF( EMPTY( cMailText ), " ", cMailText )

       DEFINE MAIL oMAIL;
         SUBJECT APP_NAME + " "; // Invio Documento: "+TIME()
         TEXT cMailText + " ";  // Invio Documento - "+ DTOC( DATE() )+' '+TIME()
         TO oV:cEmailDefaultPDF + " ";
         FILES ( cPdffilename ), cFileName( cPdfFileName ) ;
         FROM USER



      ACTIVATE MAIL oMail


  ENDIF
  
RETURN NIL
*
** eof SavePDF
Pedro Gonzalez
Posts: 31
Joined: Sun Jan 29, 2006 06:34 PM
preview to pdf using image2pdf
Posted: Wed Apr 16, 2008 01:25 PM

Hi Pymsoft

Tanks for your reply.

2 more things:

  • Can you attach the classe "MAIL "

  • How you put the icon in prev32.dll , You open it with what?

best regards

Posts: 1074
Joined: Fri Oct 07, 2005 01:56 PM
preview to pdf using image2pdf
Posted: Wed Apr 16, 2008 01:37 PM

Buenos dias

y que libreria se debe enlazar, ya que al compilar salen funciones que no existen

desde ya gracias

Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
Posts: 383
Joined: Tue Oct 11, 2005 01:01 PM
preview to pdf using image2pdf
Posted: Wed Apr 16, 2008 03:07 PM

to Pedro Faro:

the class mail is the standard with FWH
the icon i use is in my rc

Regards

para Patricio:
es una libreria de pago Image2PDF.dll que puedes probar gratuitamente.
Las funciones que faltan vienen en un .prg cuando descargas la dll.

http://www.utilitywarrior.com/Image-to-PDF.htm

Saludos

Pedro Gonzalez
Posts: 1074
Joined: Fri Oct 07, 2005 01:56 PM
preview to pdf using image2pdf
Posted: Wed Apr 16, 2008 03:14 PM

Gracias pedro

Funciono increible, pero sale "EVALUATION MODE", :o
veremos si adquerimos la licencia :-)

Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
Posts: 31
Joined: Sun Jan 29, 2006 06:34 PM
preview to pdf using image2pdf
Posted: Wed Apr 16, 2008 05:31 PM

Hi PymSoft

I include the Acrobat BitMap in my RC but it doesn't appear in the preview.

The icons of preview are in prev32.dll . It don't have to be in prev32.dll too.

Best regards

Posts: 625
Joined: Wed Mar 14, 2007 06:49 PM
preview to pdf using image2pdf
Posted: Wed Apr 16, 2008 11:16 PM

Saludos Colegas:

Solo tengo unas cuantas dudas...

He revisado y ya baje el archivo zip que contiene el demo de la DLL, as铆 como un archivo Image2PDF.PRG donde vienen funciones para su uso, tambien he agregado las lineas de c贸digo que se encuetran citadas anteriormente, pero, al agregar el archivo prg al proyecto y compilarlo muestra mensajes de que siguen faltando algunas funciones, me pregunto si lo estoy probando de forma equivocada.? :oops: :? :x :roll:

Y si fuera posible y si no es mucho pedir que nos muestren las funciones que faltan para poder completar esta prueba..

_HB_FUN_IPMETA
_HB_FUN_IPSIZE
_HB_FUN_IPMETAADJUSTTEXT
_HB_FUN_XI2PDF_BATESFORMAT
_HB_FUN_XI2PDF_BATESLOCATION
_HB_FUN_XI2PDF_BATESFONT_INT
_HB_FUN_XI2PDF_BATESBACKGROUND_INT
_HB_FUN_IPSETDPI
_HB_FUN_IPADDIMG
_HB_FUN_IPMAKEPDF

Saludos..

Soluciones y Dise帽o de Software
Damos Soluciones...

I.S.C. Victor Daniel Cuatecatl Leon
Director y Dise帽ador de Proyectos

http://www.soldisoft.unlugar.com
http://www.sisa.unlugar.com
danyleon82@hotmail.com
www.facebook.com/victordaniel.cuatecatlleon
Posts: 383
Joined: Tue Oct 11, 2005 01:01 PM
preview to pdf using image2pdf
Posted: Thu Apr 17, 2008 08:28 AM
Pedro Faro: try open prev32.dll with pellesc and add the bitmap.

Regards


Patricio:

   DLL32 STATIC FUNCTION I2PDF_License( code AS LPSTR) AS LONG;
   PASCAL FROM "I2PDF_License" LIB "IMAGE2PDF.dll"

   DLL32 STATIC FUNCTION IPMeta( ) AS LONG;
   PASCAL FROM "I2PDF_MetaToNativePDF" LIB "Image2PDF.dll"

   DLL32 STATIC FUNCTION IPMetaAdjustText() AS LONG;
   PASCAL FROM "I2PDF_MetaTextFitBoundingRect" LIB "Image2PDF.dll"

   DLL32 STATIC FUNCTION IPSize( ) AS LONG;
   PASCAL FROM "I2PDF_UseEMFDeviceSize" LIB "Image2PDF.DLL"

  //  static unsigned int I2PDF_AddImage(char *image);
   DLL32 STATIC FUNCTION IPAddImg( cImage AS LPSTR ) AS LONG;
   PASCAL FROM "I2PDF_AddImage" LIB "Image2PDF.dll"

  //  static unsigned int I2PDF_SetDPI(unsigned int dpi);
  
   DLL32 STATIC FUNCTION IPSetDpi( nDpi AS LONG ) AS LONG;
   PASCAL FROM "I2PDF_SetDPI" LIB "Image2PDF.dll"

//   static unsigned int I2PDF_MakePDF(char *output, int options, char *errorText, unsigned int maxErrorTextSize);

   DLL32 STATIC FUNCTION IPMakePDF( cOutFile AS LPSTR, nOptions AS LONG, cErrTxt AS LPSTR, nMaxESize AS LONG ) AS LONG;
   PASCAL FROM "I2PDF_MakePDF" LIB "Image2PDF.dll"

   DLL32  FUNCTION COPYFILE( cExistName AS LPSTR, cNewName AS LPSTR, nFailIfExist AS LONG ) AS BOOL;
   PASCAL FROM "CopyFileA" LIB "kernel32.dll"

   DLL32 FUNCTION xI2PDF_BatesFormat( format AS LPSTR ) AS LONG;
   PASCAL FROM "I2PDF_BatesFormat" LIB "Image2PDF.dll"


   DLL32 FUNCTION xI2PDF_BatesLocation( verticalPosition AS LONG, horizontalPosition AS LONG, orientation AS LONG, margin AS DOUBLE) AS LONG;
   PASCAL FROM "I2PDF_BatesLocation" LIB "Image2PDF.dll"

   DLL32 FUNCTION xI2PDF_BatesFont_Int( iSize AS LONG, FontID AS LPSTR, fillRed AS LONG, fillGreen AS LONG, fillBlue AS LONG, iStyle AS LONG, otherRed AS LONG, otherGreen AS LONG, otherBlue AS LONG) AS LONG;
   PASCAL FROM "I2PDF_BatesFont_Int" LIB "Image2PDF.dll"

   DLL32 FUNCTION xI2PDF_BatesBackground_Int( shape AS LONG, bkRed AS LONG, bkGreen AS LONG, bkBlue AS LONG, borderRed AS LONG, borderGreen AS LONG, borderBlue AS LONG  ) AS LONG;
   PASCAL FROM "I2PDF_BatesBackground_Int" LIB "Image2PDF.dll"


Saludos
Pedro Gonzalez
Posts: 625
Joined: Wed Mar 14, 2007 06:49 PM
preview to pdf using image2pdf
Posted: Thu Apr 17, 2008 02:36 PM

Saludos de nuevo:

Ok ya no muestra los mensajes de que faltan funciones, ahora me surge una duda, para que tipos de reportes funciona..?? TReport, TPrint o TTxtPrev, ya que en los reportes con TReport truena al momento de exportar a PDF, porque no reconoce la variable oDevice y por lo consiguiente oDevice:aMeta

Se ve prometedor y ojala y nos puedan dar un ejemplito practico en base a todo lo que esta expuesro aki para podernos darnos una idea del resultado que se obtiene, y talvez, aventarnos a comprar la licencia para su uso completo..

Saludos y Gracias anticipadas.. :lol: :lol:

Soluciones y Dise帽o de Software
Damos Soluciones...

I.S.C. Victor Daniel Cuatecatl Leon
Director y Dise帽ador de Proyectos

http://www.soldisoft.unlugar.com
http://www.sisa.unlugar.com
danyleon82@hotmail.com
www.facebook.com/victordaniel.cuatecatlleon
Posts: 383
Joined: Tue Oct 11, 2005 01:01 PM
preview to pdf using image2pdf
Posted: Thu Apr 17, 2008 04:47 PM

creo que funciona para todos los reportes que usen rpreview, visto que ahi fue hice los cambios.

saludos

Pedro Gonzalez
Posts: 625
Joined: Wed Mar 14, 2007 06:49 PM
preview to pdf using image2pdf
Posted: Thu Apr 17, 2008 05:01 PM
Gracias por el dato pymsoft:

Podrias proporcionarnos los cambios que realizaste al archivo RPreview.prg ya que le he seguido investigando y sigo teniendo problemas con los cambios que hize, este es el error que genera:

Descripci贸n del Error:
___________________________________________________

Error BASE/1004
Class: 'NIL' has no exported method: AMETA
Args:
[ 1] = U


Llamadas al Stack:
___________________________________________________

Llamado desde AMETA(0)
Llamado desde SAVEPDF(1091)
Llamado desde (b)BUILDMENU(225)
Llamado desde TMENU:COMMAND(663)
Llamado desde TWINDOW:COMMAND(954)
Llamado desde TWINDOW:HANDLEEVENT(0)
Llamado desde _FWH(3206)
Llamado desde SYSREFRESH(0)
Llamado desde STOPUNTIL(0)
Llamado desde RPREVIEW(197)
Llamado desde (b)TREPORT:NEW(182)
Llamado desde TREPORT:ACTIVATE(859)
Llamado desde IMPFACT(1915)
Llamado desde (b)LISTFACTRA(79)
Llamado desde TBUTTONBMP:CLICK(167)
Llamado desde TBUTTON:HANDLEEVENT(0)
Llamado desde TBUTTONBMP:HANDLEEVENT(0)
Llamado desde _FWH(3206)
Llamado desde SENDMESSAGE(0)
Llamado desde TDIALOG:COMMAND(404)
Llamado desde TWINDOW:HANDLEEVENT(0)
Llamado desde TDIALOG:HANDLEEVENT(916)
Llamado desde DIALOGBOX(0)
Llamado desde TDIALOG:ACTIVATE(270)
Llamado desde LISTFACTRA(105)
Llamado desde (b)PRINCIPAL(720)
Llamado desde TBTNBMP:CLICK(0)
Llamado desde TBTNBMP:LBUTTONUP(0)
Llamado desde TWINDOW:HANDLEEVENT(0)
Llamado desde TCONTROL:HANDLEEVENT(0)
Llamado desde TBTNBMP:HANDLEEVENT(0)
Llamado desde _FWH(3206)
Llamado desde WINRUN(0)
Llamado desde TWINDOW:ACTIVATE(903)
Llamado desde PRINCIPAL(821)
Llamado desde MAIN(89)

Ya que esta esta es la funci贸n con la que intento exportarla a PDF pero la variable "oDevice" no existe

//----------------------------------------------------------------------------//
FUNCTION SavePdf( oDevice, lEmail )

LOCAL imageFilename := " "
LOCAL ix
LOCAL iErr := 0
LOCAL error
LOCAL i, hLibImg2PDF
LOCAL cPdffilename := ".\DEMO.PDF" //Aki no existe la variable oV:arc_dir ni ov:work_st
LOCAL aFiles:={}
LOCAL oMail, oFontT, cMailText

DEFAULT lEmail := .F.

IF !FILE( "image2PDF.dll" )
msgStop("MANCA FILE CREAZIONE PDF", APP_NAME )
RETURN NIL
ENDIF

aFiles := oDevice:aMeta // Aki truena el metodo aMeta..


Saludos y gracias por tu tiempo
Soluciones y Dise帽o de Software
Damos Soluciones...

I.S.C. Victor Daniel Cuatecatl Leon
Director y Dise帽ador de Proyectos

http://www.soldisoft.unlugar.com
http://www.sisa.unlugar.com
danyleon82@hotmail.com
www.facebook.com/victordaniel.cuatecatlleon
Posts: 383
Joined: Tue Oct 11, 2005 01:01 PM
preview to pdf using image2pdf
Posted: Fri Apr 18, 2008 01:50 PM
Estos son los cambios que hice:


METHOD BuildButtonBar() CLASS TPreview
..
..
          IF lImage2PDF 
           DEFINE BUTTON RESOURCE "ACROBAT" OF oBar GROUP ;
              MESSAGE "Crea PDF"                 ;
              ACTION  SavePDF( ::oDevice ) ;
              TOOLTIP "Crea PDF"
  
           DEFINE BUTTON RESOURCE "SENDMAIL" OF oBar ;
              MESSAGE "Invia per Email"                 ;
              ACTION  SavePDF( ::oDevice, .T. ) ; // ::Zoom()                             ;
              TOOLTIP "Invia per Email"
          ENDIF
..


Saludos
Pedro Gonzalez
Posts: 625
Joined: Wed Mar 14, 2007 06:49 PM
preview to pdf using image2pdf
Posted: Fri Apr 18, 2008 03:43 PM
Saludos de Nuevo pymsoft y perd贸n por la insistencia..

Estan hechos los cambio y ya empezo a funcionar, pero me he dado cuenta de que muchas variables no estan definidas y por lo tanto falla al momento de pasar el reporte a PDF..

Estas son algunas de las variables que no son reconocidas y de las cuales ignoro su valor..


oV:arc_dir
ov:work_st
better.
WP_GEST_PDF
oV:nModuloWP


:-) :-) Ademas de que al intentar registrar la libreria como demo el reporte truena con error de proteccion general de Windows :-) :-)

IF lAnd( WP_GEST_PDF, oV:nModuloWP ) 
        //I2PDF_License("xxxxxxxxxxxxxxx") 
      ELSE 
           msginfo("Poniendo Licencia")
        I2PDF_License("DEMO")  // aki truena por Error de protecci贸n general.-
       msginfo("Licencia en Demo Ok") 
    ENDIF




Por eso insisto :-) en que si nos pudieran proporcionar un peque帽o ejemplo funcional con codigo completo incluido para poder examinar con detenimiento esta otra forma de exportar reportes ya que es de valiosa importancia para muchos colegas.. :-)

Gracias de nuevo y disculpen la molestia y mi insistencia..
Soluciones y Dise帽o de Software
Damos Soluciones...

I.S.C. Victor Daniel Cuatecatl Leon
Director y Dise帽ador de Proyectos

http://www.soldisoft.unlugar.com
http://www.sisa.unlugar.com
danyleon82@hotmail.com
www.facebook.com/victordaniel.cuatecatlleon
Posts: 326
Joined: Sun Oct 09, 2005 05:22 PM
preview to pdf using image2pdf
Posted: Fri Apr 18, 2008 05:39 PM

Victor, espero te sirvan estos comentarios.

Al descargar Image2PDF se obtienen dos DLLs, Image2PDF.Dll que al usarla genera GPFs, renombra y usa Image2PDF StdCall.Dll.

Agregu茅 a RPreview el c贸digo de la funci贸n SavePDF() y las DLL32 publicadas, despues de algunas compilaciones todo funciona.

No hago p煤blico el c贸dogo de RPreview porque la tengo totalmente modificada a mis necesidades, con lo que expuso Pedo me fue suficiente.

Gracias Pedro.

Solo me falta adquirir la licencia y listo!