Ghostscript language bindings

Introduction
About our APIs
Demo code
C#
Overview
GhostAPI
GhostNET
GhostMono
Java
Overview
gsjava.jar
Python
Overview
gsapi.py

# Python overview

## About

The `Python` API is provided by the file gsapi.py - this is the binding to the Ghostscript `C` library.

In the GhostPDL repository sample `Python` examples can be found in `/demos/python/examples.py`.

## Platform & setup

### Building Ghostscript

Ghostscript should be built as a shared library for your platform.

See Building Ghostscript.

## Specifying the Ghostscript shared library

Two environmental variables can be used to specify where to find the Ghostscript shared library.

`GSAPI_LIB` sets the exact path of the Ghostscript shared library, otherwise, `GSAPI_LIBDIR` sets the directory containing the Ghostscript shared library.

If neither is defined we will use the OS's default location(s) for shared libraries.

If `GSAPI_LIB` is not defined, the leafname of the shared library is inferred from the OS type - `libgs.so` on Unix, `libgs.dylib` on MacOS, `gsdll64.dll` on Windows 64.

## API test

The `gsapi.py` file that provides the `Python` bindings can also be used to test the bindings, by running it directly.

Assuming that your Ghostscript library has successfully been created, then from the root of your `ghostpdl` checkout run:

#### Windows

from ghostpdl

    // Run gsapi.py as a test script in a cmd.exe window:
    set GSAPI_LIBDIR=debugbin&& python ./demos/python/gsapi.py

    // Run gsapi.py as a test script in a PowerShell window:
    cmd /C "set GSAPI_LIBDIR=debugbin&& python ./demos/python/gsapi.py"

#### Linux/OpenBSD/MacOS

from ghostpdl

    // Run gsapi.py as a test script:
    GSAPI_LIBDIR=sodebugbin ./demos/python/gsapi.py

If there are no errors then this will have validated that the Ghostscript library is present & operational.

About
Platform & setup
Building Ghostscript
Specifying the Ghostscript shared library
API test