Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than gsapi, prefix the name with the module name and a period.
gsapi_new_instance (gsapi)
.
Creates a new instance of Ghostscript. This instance is passed to most other gsapi functions.
<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);
}
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);
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);
}
}
}
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).