Function Convert_PS_to_PDF(ByRef InputFile As String, ByRef OutputFile As String, ByRef Settings As String, ByRef Stream As Boolean, ByRef Quiet As Boolean) As Boolean Convert_PS_to_PDF = False CmdLine.Settings = Settings If Len(CmdLine.Settings) <> 24 Then CmdLine.Settings = "-P0-Q2-C0-R0-L0-E0-B1-H0" hGS = Load_DLL_Library(MyResourcesPath & "gsdll32.dll") If hGS = 0 Then Exit Function intReturn = gsapi_new_instance(intGSInstanceHandle, callerHandle) astrGSArgs(0) = "" astrGSArgs(1) = "-P-" Temp = App.Path & "\bin" astrGSArgs(2) = "-I" & Temp & ";" & Temp astrGSArgs(3) = "-q" astrGSArgs(4) = "-dNOPAUSE" astrGSArgs(5) = "-dSAFER" astrGSArgs(6) = "-dBATCH" astrGSArgs(7) = "-sDEVICE#pdfwrite" astrGSArgs(8) = "-dCompatibilityLevel#1.3" astrGSArgs(9) = "-dPDFSETTINGS#/prepress" astrGSArgs(10) = "-dAutoRotatePages#/PageByPage" astrGSArgs(11) = "-dProcessColorModel#/DeviceRGB" astrGSArgs(12) = "-sOutputFile#" & OutputFile astrGSArgs(13) = "-c" astrGSArgs(14) = "<< " astrGSArgs(14) = astrGSArgs(14) & "/EmbedAllFonts true " astrGSArgs(14) = astrGSArgs(14) & "/SubsetFonts true " If Mid$(CmdLine.Settings, 21, 1) = "0" Then astrGSArgs(14) = astrGSArgs(14) & "/NeverEmbed [ /Courier /Courier-Bold /Courier-BoldOblique /Courier-Oblique /Helvetica /Helvetica-Bold /Helvetica-BoldOblique /Helvetica-Oblique /Times-Bold /Times-BoldItalic /Times-Italic /Times-Roman ] " Else astrGSArgs(14) = astrGSArgs(14) & "/NeverEmbed [] " End If astrGSArgs(14) = astrGSArgs(14) & "/ColorConversionStrategy /UseDeviceDependentColor " astrGSArgs(14) = astrGSArgs(14) & "/ConvertCMYKImagesToRGB false " If Mid$(CmdLine.Settings, 6, 1) = "0" Then astrGSArgs(14) = astrGSArgs(14) & "/ColorImageFilter /FlateEncode " astrGSArgs(14) = astrGSArgs(14) & "/DownsampleColorImages false " ElseIf Mid$(CmdLine.Settings, 6, 1) = "1" Then astrGSArgs(14) = astrGSArgs(14) & "/ColorACSImageDict <> " ElseIf Mid$(CmdLine.Settings, 6, 1) = "2" Then astrGSArgs(14) = astrGSArgs(14) & "/ColorImageResolution 150 " astrGSArgs(14) = astrGSArgs(14) & "/ColorImageDownsampleThreshold 1.0 " astrGSArgs(14) = astrGSArgs(14) & "/ColorImageDownsampleType /Bicubic " astrGSArgs(14) = astrGSArgs(14) & "/ColorACSImageDict <> " Else astrGSArgs(14) = astrGSArgs(14) & "/DownsampleColorImages false " astrGSArgs(14) = astrGSArgs(14) & "/AutoFilterColorImages false " astrGSArgs(14) = astrGSArgs(14) & "/ColorImageResolution 75 " astrGSArgs(14) = astrGSArgs(14) & "/ColorImageDownsampleThreshold 1.0 " astrGSArgs(14) = astrGSArgs(14) & "/ColorImageDownsampleType /Bicubic " astrGSArgs(14) = astrGSArgs(14) & "/ColorACSImageDict <> " End If astrGSArgs(14) = astrGSArgs(14) & ">> setdistillerparams" astrGSArgs(15) = "-f" If Not Stream And InputFile <> "" Then astrGSArgs(16) = InputFile ElseIf Stream Then astrGSArgs(16) = "-_" Else Exit Function End If intElementCount = UBound(astrGSArgs) ReDim aAnsiArgs(intElementCount) ReDim aPtrArgs(intElementCount) For intCounter = 0 To intElementCount aAnsiArgs(intCounter) = StrConv(astrGSArgs(intCounter), vbFromUnicode) aPtrArgs(intCounter) = StrPtr(aAnsiArgs(intCounter)) Next ptrArgs = VarPtr(aPtrArgs(0)) GSpollTimer = Timer + 0.1 intResult = gsapi_init_with_args(intGSInstanceHandle, intElementCount + 1, ptrArgs) gsapi_exit (intGSInstanceHandle) gsapi_delete_instance (intGSInstanceHandle) If intResult = -101 Or intResult >= 0 Then Convert_PS_to_PDF = True ElseIf intResult = -12 Then If Not Quiet Then MsgBox "No data stream received from Printer Driver." & vbCrLf & "File not created.", vbCritical + vbOKOnly + vbMsgBoxSetForeground, "PDF reDirect v2" Else If Not Quiet Then MsgBox "PDF Engine Error. (Error Code: " & Str$(intResult) & ")" & vbCrLf & "File not created.", vbCritical + vbOKOnly + vbMsgBoxSetForeground, "PDF reDirect v2" End If FreeLibrary (hGS) Exit Function End Function