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
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"
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
..
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
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: Google [Bot] and 26 guests