@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: Creates a new instance of Ghostscript. This instance is passed to most other gsapi functions. !!!!C# Signature: [DllImport("gsdll32.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] private static extern int gsapi_new_instance(ref System.IntPtr pinstance, System.IntPtr handle); !!!!VB Signature: <DllImport("gsdll32.dll", CharSet:= CharSet.Ansi, CallingConvention:= CallingConvention.StdCall)> _ Private Shared Function gsapi_new_instance(ByRef pinstance As System.IntPtr, ByVal handle As System.IntPtr) As Integer End Function !!!!User-Defined Types: None. !!!!Alternative Managed API: Do you know one? Please contribute it! !!!!Notes: None. !!!!Tips & Tricks: When working with the gsapi.dll, start with the gsapi_revision function, get that working. Then get this api working next. !!!!Sample Code: /* Keep this variable at a class scope. It will be used by almost all of the gsapi functions */ System.IntPtr pinstance= IntPtr.Zero; private void button1_Click(object sender, EventArgs e) { /* Pass in the reference to pinstance, declared above. Assume "this" is a Windows Form, so it will have a Handle */ int retVal = gsapi_new_instance(ref pinstance, this.Handle); } Documentation: http://www.cs.wisc.edu/~ghost/doc/cvs/API.htm !!!!Sample Code: // c# console program to call Ghostscript using System; using System.Runtime.InteropServices; namespace GPL { public class Ghostscript { [StructLayout(LayoutKind.Sequential)] public struct GSVersion { public string product; public string copyright; public int revision; public int revisionDate; } [DllImport("gsdll32.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] private static extern int gsapi_revision(ref GSVersion version, int len); [DllImport("gsdll32.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] private static extern int gsapi_new_instance(ref System.IntPtr pinstance, System.IntPtr handle); [DllImport("gsdll32.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] private static extern int gsapi_init_with_args(IntPtr pInstance, int argc, [In, Out] string[] argv); [DllImport("gsdll32.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] private static extern int gsapi_exit(IntPtr instance); [DllImport("gsdll32.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] private static extern void gsapi_delete_instance(System.IntPtr pinstance); public static void getVersion(ref GSVersion version) { gsapi_revision(ref version, Marshal.SizeOf(version)); } public static void run(string[] argv) { IntPtr inst = IntPtr.Zero; int code = gsapi_new_instance(ref inst, IntPtr.Zero); if (code != 0) return; code = gsapi_init_with_args(inst, argv.Length, argv); gsapi_exit(inst); gsapi_delete_instance(inst); } } class Program { static void Main(string[] args) { Ghostscript.GSVersion gsVer = new Ghostscript.GSVersion(); Ghostscript.getVersion(ref gsVer); // execute this command, to convert pdf to tiff // "C:\Program Files (x86)\gs\gs9.00\bin\gswin32c" -q -sOutputFile=D:\temp\Planung.tif -dNOPAUSE -dBATCH -P- -dSAFER -sDEVICE#tiffpack -r100 D:\temp\Planung.pdf string[] argv = { "flashReader", "-q", "-sOutputFile=C:\\temp\\Outfile.tif", "-dNOPAUSE", "-dBATCH", "-P-", "-dSAFER", "-sDEVICE=tiffpack", "-r100", "C:\\temp\\Infile.pdf" }; Ghostscript.run(argv); } } }
Edit gsapi.gsapi_new_i...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.