FUNCTION SavePDF(oDevice)
LOCAL error, hLibImg2PDF
LOCAL imageFilename:=" "
LOCAL cPdfFilename
LOCAL nI, iErr:=0
LOCAL aFiles:={}, cTemp
cPdfFileName:=cUTem+"\"+Left(cNSys,2)+"_Temp\"+oDevice:cDocument+".Pdf"
IF !File("Image2PDF.Dll")
MsgAlert("No existe DLL para generar PDFs.","Precaución!")
RETURN (NIL)
ENDIF
aFiles:=oDevice:aMeta
hLibImg2PDF:=LoadLib32("Image2PDF.Dll")
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 !File(cPdfFileName)
MsgInfo("No se generó el archivo PDF.","Información!")
ELSE
ShellExecute(,"Open",cPdfFileName,"",".\",.T.)
ENDIF
RETURN (NIL)
//----------------------------------------------------------------------------//
DLL32 FUNCTION I2PDF_License( code AS LPSTR) AS LONG;
PASCAL FROM "I2PDF_License" LIB "IMAGE2PDF.dll"
DLL32 FUNCTION IPMeta( ) AS LONG;
PASCAL FROM "I2PDF_MetaToNativePDF" LIB "Image2PDF.dll"
DLL32 FUNCTION IPMetaAdjustText() AS LONG;
PASCAL FROM "I2PDF_MetaTextFitBoundingRect" LIB "Image2PDF.dll"
DLL32 FUNCTION IPSize( ) AS LONG;
PASCAL FROM "I2PDF_UseEMFDeviceSize" LIB "Image2PDF.DLL"
DLL32 FUNCTION IPAddImg( cImage AS LPSTR ) AS LONG;
PASCAL FROM "I2PDF_AddImage" LIB "Image2PDF.dll"
DLL32 FUNCTION IPSetDpi( nDpi AS LONG ) AS LONG;
PASCAL FROM "I2PDF_SetDPI" LIB "Image2PDF.dll"
DLL32 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"
//----------------------------------------------------------------------------//