Page 1 of 1

Another more about RPreview and Image2PDF

PostPosted: Wed Dec 23, 2009 9:48 pm
by Blessed
Hello friends of the forum.

I've been testing the evaluation Image2PDF DLL, I made use of "RPrevUserBtns" from the main program for which I work on all reports and works well:

Code: Select all  Expand view
RPrevUserBtns( { | oPrev, oBar | MyButtons( oPrev, oBar ) } )  && Botones adicionales

...

FUNCTION MyButtons( oPreview, oBar )

   DEFINE BUTTON OF oBar RESOURCE "PDF" ACTION SavePDF( oPreview:oDevice ) ;
          TOOLTIP "Generar archivo PDF"

   DEFINE BUTTON OF oBar RESOURCE "Email" ACTION Send2Email( oPreview ) ;
          TOOLTIP "Enviar en email como archivo PDF adjunto"

   RETURN NIL
 


The code to use with Image2PDF (Posted below) only converts the text of the report, I can not see images in the preview, this is because the evaluation version or there is an error?
Someone has done a completely Image2PDF, I can help.

Code: Select all  Expand view
FUNCTION SavePDF( oDevice, cMyNombrePDF )

   LOCAL error, hLibImg2PDF
   LOCAL imageFilename:=" "
   LOCAL cPdfFilename
   LOCAL nI, iErr:=0
   LOCAL aFiles:={}, cTemp

   cPdfFileName:= oApp:Path_PDF + oDevice:cDocument + ".Pdf"
   aFiles:=oDevice:aMeta
   hLibImg2PDF:=LoadLib32( "Image2PDF" )

   IF ValType(aFiles)=="A"
      I2PDF_License("LICENCIA")
      iErr:=IPMeta()              // Flag that his is a meta file
      iErr:=IPSize()              // Reset the size
      iErr:=IPMetaAdjustText()
      iErr:=IPSetDPI(0)           // Set DPI to the default for PDF's.  It works better
      FOR nI:=1 TO Len(aFiles)    // Build the pages using the array of temp files
         CursorWait()
         imageFilename:=aFiles[nI]
         iErr:=IPAddImg(imageFilename)
      NEXT nI
      CursorWait()
      iErr:=IPMakePDF(cPdfFileName,0,error,40)   // Create the PDF.
   ENDIF

   FreeLib32(hLibImg2PDF)
   CursorArrow()
   IF cMyNombrePDF != NIL
      cMyNombrePDF := cPdfFileName
   ELSE
      IF !File(cPdfFileName)
         MsgInfo("No se generó el archivo PDF.","Información!")
      ELSE
         ShellExecute(,"Open",cPdfFileName,"",".\",.T.)
      ENDIF
   ENDIF
   
RETURN (NIL)

//--- Wrappers ---------------------------------------------------------------//

   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"

   DLL32 STATIC FUNCTION IPAddImg( cImage AS LPSTR ) AS LONG;
   PASCAL FROM "
I2PDF_AddImage" LIB "Image2PDF.dll"

   DLL32 STATIC FUNCTION IPSetDpi( nDpi AS LONG ) AS LONG;
   PASCAL FROM "
I2PDF_SetDPI" LIB "Image2PDF.dll"

   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 LONG) 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"



Thanks in advance.

Best regards :)

Re: Another more about RPreview and Image2PDF

PostPosted: Wed Dec 23, 2009 11:57 pm
by Blessed
Hello again

I just wanted to make mention that the images, are on the same page.
I know I can add pictures in a different page.

With the instruction:

Code: Select all  Expand view
iErr:=IPAddImg(imageFilename)


Sooner or later, but I need the image is on the same page.

Thanks in advance.

Best regards :)

Re: Another more about RPreview and Image2PDF

PostPosted: Thu Dec 24, 2009 5:06 am
by Richard Chidiak
There is no problem having images in the same page , i don't know about ehe evaluation version , maybe ...

try adding this

iErr := I2PDF_MetaToNativePDF()
iErr := I2PDF_MetaTextFitBoundingRect()
iErr := I2PDF_UseEMFDeviceSize( )
iErr := I2PDF_SetDPI(0) // Set PDF DPI to the same as the image
iErr := I2PDF_MetamMargins()

I use Image2pdf since several years and it is an excellent product

HTH

Richard

Re: Another more about RPreview and Image2PDF

PostPosted: Fri Dec 25, 2009 6:46 am
by Blessed
Richard, I appreciate your time.

Try suggesting, not turned, and still more, download the trial version 2.52, and neither, I will be inclined to think that being a demo.

Yet despite that, engaging in the purchase.

Best regards

Re: Another more about RPreview and Image2PDF

PostPosted: Mon Aug 02, 2010 3:50 pm
by Miguel Salas
hola
necesito convertir wmf a pdf, pero en este codigo no veo como enviar el oPreview...¿?

alguien tiene el codigo completo
gracias
saludos