Option Explicit On/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Imports System.Runtime.InteropServices/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Module gsapiModule gsapi/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Declare Sub CopyMemory()Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal dest As IntPtr, ByVal source As IntPtr, ByVal bytes As Long)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'UDTs Start/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
<StructLayout(LayoutKind.Sequential)> Public Structure GS_RevisionStructure GS_Revision/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public strProduct As IntPtr/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public strCopyright As IntPtr/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public intRevision As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public intRevisionDate As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End Structure/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'UDTs End/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'Callback Functions Start/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'These are only required if you use gsapi_set_stdio/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Delegate Function StdioCallBack()Function StdioCallBack(ByVal handle As IntPtr, ByVal strptr As IntPtr, ByVal count As Integer) As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Function gsdll_stdin()Function gsdll_stdin(ByVal intGSInstanceHandle As IntPtr, ByVal strz As IntPtr, ByVal intBytes As Integer) As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' This is dumb code that reads one byte at a time/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Ghostscript doesn't mind this, it is just very slow/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
If intBytes = 0 Then/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
gsdll_stdin = 0/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Else/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim ich As Integer = Console.Read()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
If ich = -1 Then/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
gsdll_stdin = 0 ' EOF/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Else/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim bch As Byte = ich/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim gcByte As GCHandle = GCHandle.Alloc(bch, GCHandleType.Pinned)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim ptrByte As IntPtr = gcByte.AddrOfPinnedObject()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
CopyMemory(strz, ptrByte, 1)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
ptrByte = IntPtr.Zero/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
gcByte.Free()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
gsdll_stdin = 1/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End If/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End If/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End Function/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Function gsdll_stdout()Function gsdll_stdout(ByVal intGSInstanceHandle As IntPtr, ByVal strz As IntPtr, ByVal intBytes As Integer) As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' If you can think of a more efficient method, please tell me!/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' We need to convert from a byte buffer to a string/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' First we create a byte array of the appropriate size/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim aByte(intBytes) As Byte/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Then we get the address of the byte array/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim gcByte As GCHandle = GCHandle.Alloc(aByte, GCHandleType.Pinned)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim ptrByte As IntPtr = gcByte.AddrOfPinnedObject()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Then we copy the buffer to the byte array/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
CopyMemory(ptrByte, strz, intBytes)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Release the address locking/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
ptrByte = IntPtr.Zero/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
gcByte.Free()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Then we copy the byte array to a string, character by character/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim str As String/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim i As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
For i = 0 To intBytes - 1/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
str = str + Chr(aByte(i))/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Next/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Finally we output the message/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Console.Write(str)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
gsdll_stdout = intBytes/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End Function/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Function gsdll_stderr()Function gsdll_stderr(ByVal intGSInstanceHandle As IntPtr, ByVal strz As IntPtr, ByVal intBytes As Integer) As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
gsdll_stderr = gsdll_stdout(intGSInstanceHandle, strz, intBytes)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End Function/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'Callback Functions End/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'API Calls Start/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'Win32 API/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'GhostScript API/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Public Declare Function gsapi_revision Lib "gsdll32.dll" (ByVal pGSRevisionInfo As IntPtr, ByVal intLen As Integer) As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Declare Function gsapi_revision()Function gsapi_revision Lib "gsdll32.dll" (ByRef pGSRevisionInfo As GS_Revision, ByVal intLen As Integer) As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Declare Function gsapi_new_instance()Function gsapi_new_instance Lib "gsdll32.dll" (ByRef lngGSInstance As IntPtr, ByVal lngCallerHandle As IntPtr) As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Declare Function gsapi_set_stdio()Function gsapi_set_stdio Lib "gsdll32.dll" (ByVal lngGSInstance As IntPtr, ByVal gsdll_stdin As StdioCallBack, ByVal gsdll_stdout As StdioCallBack, ByVal gsdll_stderr As StdioCallBack) As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Declare Sub gsapi_delete_instance()Sub gsapi_delete_instance Lib "gsdll32.dll" (ByVal lngGSInstance As IntPtr)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Declare Function gsapi_init_with_args()Function gsapi_init_with_args Lib "gsdll32.dll" (ByVal lngGSInstance As IntPtr, ByVal lngArgumentCount As Integer, ByVal lngArguments As IntPtr) As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Declare Function gsapi_run_file()Function gsapi_run_file Lib "gsdll32.dll" (ByVal lngGSInstance As IntPtr, ByVal strFileName As String, ByVal intErrors As Integer, ByVal intExitCode As Integer) As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Declare Function gsapi_exit()Function gsapi_exit Lib "gsdll32.dll" (ByVal lngGSInstance As IntPtr) As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'API Calls End/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'User Defined Functions Start/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Function StringToAnsiZ()Function StringToAnsiZ(ByVal str As String) As Byte()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Convert a Unicode string to a null terminated Ansi string for Ghostscript./°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' The result is stored in a byte array. Later you will need to convert/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' this byte array to a pointer with GCHandle.Alloc(XXXX, GCHandleType.Pinned)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' and GSHandle.AddrOfPinnedObject()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim intElementCount As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim intCounter As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim aAnsi() As Byte/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim bChar As Byte/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
intElementCount = Len(str)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
ReDim aAnsi(intElementCount + 1)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
For intCounter = 0 To intElementCount - 1/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
bChar = Asc(Mid(str, intCounter + 1, 1))/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
aAnsi(intCounter) = bChar/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Next intCounter/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
aAnsi(intElementCount) = 0/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
StringToAnsiZ = aAnsi/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End Function/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Function AnsiZtoString()Function AnsiZtoString(ByVal strz As IntPtr) As String/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' We need to convert from a byte buffer to a string/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim byteCh(1) As Byte/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim bOK As Boolean = True/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim gcbyteCh As GCHandle = GCHandle.Alloc(byteCh, GCHandleType.Pinned)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim ptrByte As IntPtr = gcbyteCh.AddrOfPinnedObject()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim j As Integer = 0/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim str As String/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
While bOK/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' This is how to do pointer arithmetic!/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim sPtr As New IntPtr(strz.ToInt64() + j)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
CopyMemory(ptrByte, sPtr, 1)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
If byteCh(0) = 0 Then/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
bOK = False/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Else/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
str = str + Chr(byteCh(0))/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End If/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
j = j + 1/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End While/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
AnsiZtoString = str/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End Function/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Function CheckRevision()Function CheckRevision(ByVal intRevision As Integer) As Boolean/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Check revision number of Ghostscript/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim intReturn As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim udtGSRevInfo As GS_Revision/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim gcRevision As GCHandle/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
gcRevision = GCHandle.Alloc(udtGSRevInfo, GCHandleType.Pinned)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
intReturn = gsapi_revision(udtGSRevInfo, 16)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Console.WriteLine("Revision = " & udtGSRevInfo.intRevision)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Console.WriteLine("RevisiProduct = " & AnsiZtoString(udtGSRevInfo.strProduct))/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Console.WriteLine("Copyright = " & AnsiZtoString(udtGSRevInfo.strCopyright))/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
If udtGSRevInfo.intRevision = intRevision Then/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
CheckRevision = True/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Else/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
CheckRevision = False/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End If/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
gcRevision.Free()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End Function/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Public Function CallGS()Function CallGS(ByVal astrGSArgs() As String) As Boolean/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim intReturn As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim intGSInstanceHandle As IntPtr/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim aAnsiArgs() As Object/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim aPtrArgs() As IntPtr/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim aGCHandle() As GCHandle/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim intCounter As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim intElementCount As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim iTemp As Integer/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim callerHandle As IntPtr/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim gchandleArgs As GCHandle/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim intptrArgs As IntPtr/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Print out the revision details./°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' If we want to insist on a particular version of Ghostscript/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' we should check the return value of CheckRevision()./°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
CheckRevision(704)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Load Ghostscript and get the instance handle/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
intReturn = gsapi_new_instance(intGSInstanceHandle, callerHandle)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
If (intReturn < 0) Then/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Return (False)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End If/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Capture stdio/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim stdinCallback As StdioCallBack/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
stdinCallback = AddressOf gsdll_stdin/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim stdoutCallback As StdioCallBack/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
stdoutCallback = AddressOf gsdll_stdout/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim stderrCallback As StdioCallBack/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
stderrCallback = AddressOf gsdll_stderr/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
intReturn = gsapi_set_stdio(intGSInstanceHandle, stdinCallback, stdoutCallback, stderrCallback)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
If (intReturn >= 0) Then/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Convert the Unicode strings to null terminated ANSI byte arrays/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' then get pointers to the byte arrays./°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
intElementCount = UBound(astrGSArgs)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
ReDim aAnsiArgs(intElementCount)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
ReDim aPtrArgs(intElementCount)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
ReDim aGCHandle(intElementCount)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
For intCounter = 0 To intElementCount/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
aAnsiArgs(intCounter) = StringToAnsiZ(astrGSArgs(intCounter))/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
aGCHandle(intCounter) = GCHandle.Alloc(aAnsiArgs(intCounter), GCHandleType.Pinned)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
aPtrArgs(intCounter) = aGCHandle(intCounter).AddrOfPinnedObject()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Next/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
gchandleArgs = GCHandle.Alloc(aPtrArgs, GCHandleType.Pinned)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
intptrArgs = gchandleArgs.AddrOfPinnedObject()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
callerHandle = IntPtr.Zero/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
intReturn = gsapi_init_with_args(intGSInstanceHandle, intElementCount + 1, intptrArgs)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Release the pinned memory/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
For intCounter = 0 To intElementCount/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
aGCHandle(intCounter).Free()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Next/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
gchandleArgs.Free()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' Stop the Ghostscript interpreter/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
gsapi_exit(intGSInstanceHandle)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End If/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
' release the Ghostscript instance handle/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
gsapi_delete_instance(intGSInstanceHandle)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
If (intReturn >= 0) Then/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
CallGS = True/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Else/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
CallGS = False/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End If/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End Function/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Private Function ConvertFile()Function ConvertFile() As Boolean/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim astrArgs(10) As String/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(0) = "ps2pdf" 'The First Parameter is Ignored/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(1) = "-dNOPAUSE"/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(2) = "-dBATCH"/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(3) = "-dSAFER"/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(4) = "-r300"/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(5) = "-sDEVICE=pdfwrite"/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(6) = "-sOutputFile=c:\out.pdf"/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(7) = "-c"/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(8) = ".setpdfwrite"/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(9) = "-f"/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(10) = "c:\gs\gs7.04\examples\colorcir.ps"/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Return CallGS(astrArgs)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End Function/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Private Function InteractiveGS()Function InteractiveGS() As Boolean/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Dim astrArgs(2) As String/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(0) = "gs" 'The First Parameter is Ignored/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(1) = "-c"/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
astrArgs(2) = "systemdict /start get exec"/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Return CallGS(astrArgs)/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End Function/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'User Defined Functions End/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'------------------------------------------------/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
Sub Main()Sub Main()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
ConvertFile()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
'InteractiveGS()/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
MsgBox("Done")/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End Sub/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O
End Module/°Î!&ÏS®À®forum.entlib.net.cnx5%æá´O