CLEAR DLLS >* GhostScript API >DECLARE Long gsapi_revision IN gsdll32.dll ; > Long pGSRevisionInfo, Long intLen >DECLARE Long gsapi_new_instance IN gsdll32.dll ; > Long @lngGSInstance, Long lngCallerHandle >DECLARE Long gsapi_delete_instance In gsdll32.dll ; > Long lngGSInstance >DECLARE Long gsapi_init_with_args IN gsdll32.dll ; > Long lngGSInstance, Long lngArgumentCount, ; > Long lngArguments >DECLARE Long gsapi_exit IN gsdll32.dll ; > Long lngGSInstance > >SET PROCEDURE TO clsheap ADDITIVE >? ConvertFile("H:\temp\gs\alphabet.ps", "H:\temp\gs\alphabet.pdf") >RETURN >*------------------------------------------------------- > >FUNCTION ConvertFile(tcFileIn, tcFileOut) >DIMENSION laArgs[11] >laArgs[1] = "ps2pdf" &&The First Parameter is Ignored >laArgs[2] = "-dNOPAUSE" >laArgs[3] = "-dBATCH" >laArgs[4] = "-dSAFER" >laArgs[5] = "-r300" >laArgs[6] = "-sDEVICE=pdfwrite" >laArgs[7] = "-sOutputFile=" + tcFileOut >laArgs[8] = "-c" >laArgs[9] = ".setpdfwrite" >laArgs[10] = "-f" >laArgs[11] = tcFileIn >RETURN CallGS(@laArgs) >*------------------------------------------------------- > >FUNCTION CallGS(taArgs) >loHeap = Createobject('Heap') >lnGSInstanceHandle = 0 >lnCallerHandle = 0 >* Load Ghostscript and get the instance handle >lnReturn = gsapi_new_instance(@lnGSInstanceHandle, @lnCallerHandle) >IF (lnReturn < 0) > loHeap = Null > RETURN .F. >ENDIF >* Convert the strings to null terminated ANSI byte arrays >* then get pointers to the byte arrays. >lnElementCount = ALEN(taArgs) >lcPtrArgs = "" >FOR lnCounter = 1 To lnElementCount > lcPtrArgs = lcPtrArgs + NumToLONG(loHeap.AllocString(taArgs[lnCounter])) >ENDFOR >lnPtr = loHeap.AllocBlob(lcPtrArgs) > >lnReturn = gsapi_init_with_args(lnGSInstanceHandle, lnElementCount, lnPtr) > >* Stop the Ghostscript interpreter >gsapi_exit (lnGSInstanceHandle) >* release the Ghostscript instance handle' >gsapi_delete_instance (lnGSInstanceHandle) >loHeap = Null >RETURN lnReturn >*------------------------------------------------------- > >FUNCTION GSVersion(taVersion) >DIMENSION taVersion[4] >loHeap = Createobject('Heap') >lcGSRevision = NumToLong(0) + NumToLong(0) + NumToLong(0) + NumToLong(0) >lnPtr = loHeap.AllocBlob(lcGSRevision) >lnReturn = gsapi_revision(lnPtr, 16) >lnReturn = gsapi_revision(lnPtr, 16) >lcGSRevision = loHeap.CopyFrom(lnPtr) >taVersion[1] = GetMemString(LONGToNum(Substr(lcGSRevision,1,4))) >taVersion[2] = GetMemString(LONGToNum(Substr(lcGSRevision,5,4))) >taVersion[3] = LONGToNum(Substr(lcGSRevision,9,4)) >taVersion[4] = LONGToNum(Substr(lcGSRevision,13,4)) >loHeap = Null >RETURN >As a bonus it includes function GSVersion() that returns DLL's revision info.