Package org.ghost4j
Interface GhostscriptLibrary
- All Superinterfaces:
com.sun.jna.Library
public interface GhostscriptLibrary
extends com.sun.jna.Library
Interface (JNA) bridging Ghostscript API (C language) with Java. All API
methods are bridged except for: gsapi_set_poll and gsapi_set_visual_tracer.
Note: in this interface variable names are kept unchanged compared with the C
API. Ghostscript API documentation can be found here:
http://ghostscript.com/doc/8.54/API.htm
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Structure defining display callback functions.static class
Pointer holding a native Ghostscript instance.static class
Structure in charge of holding Ghostscript revision data.static interface
Callback called to provide a custom error output to Ghostscript.static interface
Callback called to provide a custom input to Ghostscript.static interface
Callback called to provide a custom output to Ghostscript.Nested classes/interfaces inherited from interface com.sun.jna.Library
com.sun.jna.Library.Handler
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final GhostscriptLibrary
Static instance of the library itself.Fields inherited from interface com.sun.jna.Library
OPTION_ALLOW_OBJECTS, OPTION_CALLING_CONVENTION, OPTION_CLASSLOADER, OPTION_FUNCTION_MAPPER, OPTION_INVOCATION_MAPPER, OPTION_OPEN_FLAGS, OPTION_STRING_ENCODING, OPTION_STRUCTURE_ALIGNMENT, OPTION_SYMBOL_PROVIDER, OPTION_TYPE_MAPPER
-
Method Summary
Modifier and TypeMethodDescriptionvoid
gsapi_delete_instance
(com.sun.jna.Pointer instance) Destroy an instance of Ghostscript.int
gsapi_exit
(com.sun.jna.Pointer instance) Exit the interpreter.int
gsapi_init_with_args
(com.sun.jna.Pointer instance, int argc, String[] argv) Initialise the interpreter.int
gsapi_new_instance
(com.sun.jna.Pointer pinstance, com.sun.jna.Pointer caller_handle) Create a new instance of Ghostscript.int
gsapi_revision
(com.sun.jna.Structure pr, int len) This function returns the revision numbers and strings of the Ghostscript interpreter library.int
gsapi_run_file
(com.sun.jna.Pointer instance, String file_name, int user_errors, com.sun.jna.ptr.IntByReference pexit_code) Send instructions from a file to the Ghostscript interpreter.int
gsapi_run_string
(com.sun.jna.Pointer instance, String str, int user_errors, com.sun.jna.ptr.IntByReference pexit_code) Send instruction to the Ghostscript interpreter.int
gsapi_run_string_begin
(com.sun.jna.Pointer instance, int user_errors, com.sun.jna.ptr.IntByReference pexit_code) Open an instruction block to the Ghostscript interpreter.int
gsapi_run_string_continue
(com.sun.jna.Pointer instance, String str, int length, int user_errors, com.sun.jna.ptr.IntByReference pexit_code) Send instruction to the Ghostscript interpreter.int
gsapi_run_string_end
(com.sun.jna.Pointer instance, int user_errors, com.sun.jna.ptr.IntByReference pexit_code) Close an instruction block to the Ghostscript interpreter.int
gsapi_run_string_with_length
(com.sun.jna.Pointer instance, String str, int length, int user_errors, com.sun.jna.ptr.IntByReference pexit_code) Send instruction to the Ghostscript interpreter.int
gsapi_set_arg_encoding
(com.sun.jna.Pointer instance, int encoding) Set the encoding used for the interpretation of all subsequent args supplied via the gsapi interface on this instance.int
gsapi_set_display_callback
(com.sun.jna.Pointer instance, com.sun.jna.Structure callback) Set the callback structure for the display device.int
gsapi_set_stdio
(com.sun.jna.Pointer instance, GhostscriptLibrary.stdin_fn stdin_fn, GhostscriptLibrary.stdout_fn stdout_fn, GhostscriptLibrary.stderr_fn stderr_fn) Set the callback functions for stdio.
-
Field Details
-
GS_ARG_ENCODING_UTF8
static final int GS_ARG_ENCODING_UTF8- See Also:
-
instance
Static instance of the library itself.
-
-
Method Details
-
gsapi_revision
int gsapi_revision(com.sun.jna.Structure pr, int len) This function returns the revision numbers and strings of the Ghostscript interpreter library. You should call it before any other interpreter library functions to make sure that the correct version of the Ghostscript interpreter has been loaded.- Parameters:
pr
- Pointer to the gsapi_revision_s that will hold return values.len
- pr Length- Returns:
- 0 if everything is OK, invalid input: '<' 0 otherwise
- See Also:
-
gsapi_new_instance
int gsapi_new_instance(com.sun.jna.Pointer pinstance, com.sun.jna.Pointer caller_handle) Create a new instance of Ghostscript. This instance is passed to most other gsapi functions. The caller_handle will be provided to callback functions. At this stage, Ghostscript supports only one instance.- Parameters:
pinstance
- Pointer to gs_main_instance that will hold the Ghostscript instance.caller_handle
- Caller handler pointer (may be null).- Returns:
- 0 if everything is OK, invalid input: '<' 0 otherwise
-
gsapi_delete_instance
void gsapi_delete_instance(com.sun.jna.Pointer instance) Destroy an instance of Ghostscript. Before you call this, Ghostscript must have finished. If Ghostscript has been initialised, you must call gsapi_exit before gsapi_delete_instance.- Parameters:
instance
- Pointer to the Ghostscript instance.
-
gsapi_exit
int gsapi_exit(com.sun.jna.Pointer instance) Exit the interpreter. This must be called on shutdown if gsapi_init_with_args() has been called, and just before gsapi_delete_instance().- Parameters:
instance
- Pointer to the Ghostscript instance.- Returns:
- 0 if everything is OK, invalid input: '<' 0 otherwise
-
gsapi_set_arg_encoding
int gsapi_set_arg_encoding(com.sun.jna.Pointer instance, int encoding) Set the encoding used for the interpretation of all subsequent args supplied via the gsapi interface on this instance. By default we expect args to be in encoding 0 (the 'local' encoding for this OS). On Windows this means "the currently selected codepage". On Linux this typically means utf8. This means that omitting to call this function will leave Ghostscript running exactly as it always has. Please note that use of the 'local' encoding is now deprecated and should be avoided in new code. This must be called after gsapi_new_instance() and before gsapi_init_with_args().- Parameters:
instance
-encoding
-- Returns:
-
gsapi_init_with_args
Initialise the interpreter. This calls gs_main_init_with_args() in imainarg.c. The arguments are the same as the "C" main function: argv[0] is ignored and the user supplied arguments are argv[1] to argv[argc-1].- Parameters:
instance
- Pointer to the Ghostscript instance.argc
- Argument countargv
- Argument array- Returns:
- 0 if everything is OK, invalid input: '<' 0 otherwise
-
gsapi_run_string
int gsapi_run_string(com.sun.jna.Pointer instance, String str, int user_errors, com.sun.jna.ptr.IntByReference pexit_code) Send instruction to the Ghostscript interpreter. The address passed in pexit_code will be used to return the exit code for the interpreter in case of a quit or fatal error.- Parameters:
instance
- Pointer to the Ghostscript instance.str
- Instructions. Max length for the string is 65535.user_errors
- If set to 0 errors are returned the normal way (to the interpreter output), if a negative value is used errors are returns directly by the function.pexit_code
- Pointer to the exit return code- Returns:
- 0 if everything is OK, invalid input: '<' 0 otherwise
-
gsapi_run_string_with_length
int gsapi_run_string_with_length(com.sun.jna.Pointer instance, String str, int length, int user_errors, com.sun.jna.ptr.IntByReference pexit_code) Send instruction to the Ghostscript interpreter. The address passed in pexit_code will be used to return the exit code for the interpreter in case of a quit or fatal error.- Parameters:
instance
- Pointer to the Ghostscript instance.str
- Instructions. Max length for the string is 65535.length
- str length.user_errors
- If set to 0 errors are returned the normal way (to the interpreter output), if a negative value is used errors are returns directly by the function.pexit_code
- Pointer to the exit return code- Returns:
- 0 if everything is OK, invalid input: '<' 0 otherwise
-
gsapi_run_string_begin
int gsapi_run_string_begin(com.sun.jna.Pointer instance, int user_errors, com.sun.jna.ptr.IntByReference pexit_code) Open an instruction block to the Ghostscript interpreter. The address passed in pexit_code will be used to return the exit code for the interpreter in case of a quit or fatal error.- Parameters:
instance
- Pointer to the Ghostscript instance.user_errors
- If set to 0 errors are returned the normal way (to the interpreter output), if a negative value is used errors are returns directly by the function.pexit_code
- Pointer to the exit return code- Returns:
- 0 if everything is OK, invalid input: '<' 0 otherwise
-
gsapi_run_string_continue
int gsapi_run_string_continue(com.sun.jna.Pointer instance, String str, int length, int user_errors, com.sun.jna.ptr.IntByReference pexit_code) Send instruction to the Ghostscript interpreter. Must be used after gsapi_run_string_begin is called. The address passed in pexit_code will be used to return the exit code for the interpreter in case of a quit or fatal error.- Parameters:
instance
- Pointer to the Ghostscript instance.str
- Instructions. Max length for the string is 65535.length
- str length.user_errors
- If set to 0 errors are returned the normal way (to the interpreter output), if a negative value is used errors are returns directly by the function.pexit_code
- Pointer to the exit return code- Returns:
- 0 if everything is OK, invalid input: '<' 0 otherwise
-
gsapi_run_string_end
int gsapi_run_string_end(com.sun.jna.Pointer instance, int user_errors, com.sun.jna.ptr.IntByReference pexit_code) Close an instruction block to the Ghostscript interpreter. The address passed in pexit_code will be used to return the exit code for the interpreter in case of a quit or fatal error.- Parameters:
instance
- Pointer to the Ghostscript instance.user_errors
- If set to 0 errors are returned the normal way (to the interpreter output), if a negative value is used errors are returns directly by the function.pexit_code
- Pointer to the exit return code- Returns:
- 0 if everything is OK, invalid input: '<' 0 otherwise
-
gsapi_run_file
int gsapi_run_file(com.sun.jna.Pointer instance, String file_name, int user_errors, com.sun.jna.ptr.IntByReference pexit_code) Send instructions from a file to the Ghostscript interpreter.- Parameters:
instance
- Pointer to the Ghostscript instance.file_name
- File name.user_errors
- If set to 0 errors are returned the normal way (to the interpreter output), if a negative value is used errors are returns directly by the function.pexit_code
-- Returns:
- 0 if everything is OK, invalid input: '<' 0 otherwise
-
gsapi_set_stdio
int gsapi_set_stdio(com.sun.jna.Pointer instance, GhostscriptLibrary.stdin_fn stdin_fn, GhostscriptLibrary.stdout_fn stdout_fn, GhostscriptLibrary.stderr_fn stderr_fn) Set the callback functions for stdio. The stdin callback function should return the number of characters read, 0 for EOF, or -1 for error. The stdout and stderr callback functions should return the number of characters written.- Parameters:
instance
- Pointer to the Ghostscript instance.stdin_fn
- Stdin callback function.stdout_fn
- Stdout callback function.stderr_fn
- Stderr callback function.- Returns:
- 0 if everything is OK, invalid input: '<' 0 otherwise
-
gsapi_set_display_callback
int gsapi_set_display_callback(com.sun.jna.Pointer instance, com.sun.jna.Structure callback) Set the callback structure for the display device. If the display device is used, this must be called after gsapi_new_instance() and before gsapi_init_with_args(). See gdevdsp.h for more details.- Parameters:
instance
- Pointer to the Ghostscript instance.callback
- display_callback_s Structure holding display callback functions.- Returns:
- 0 if everything is OK, invalid input: '<' 0 otherwise
-