Package org.ghost4j
Class Ghostscript
java.lang.Object
org.ghost4j.Ghostscript
Class representing the Ghostscript interpreter.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static DisplayCallback
Display callback used to handle display.private static DisplayData
Stores display data when working with display callback.private static Ghostscript
Holds singleton instance.private static GhostscriptLibrary.display_callback_s
Holds the native display callback.private static GhostscriptLibrary.gs_main_instance.ByReference
Holds Ghostscript interpreter native instance (C pointer).static final String
Name of the system property used to set the encoding to use for stdin.private static OutputStream
Error output stream.private static InputStream
Standard input stream.private static OutputStream
Standard output stream. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildNativeDisplayCallback
(DisplayCallback displayCallback) Builds a native display callback from a DisplayCallback object.static void
Deletes the singleton instance of the Ghostscript object.void
exit()
Exits Ghostscript interpreter.Gets the display callback set on the Ghostscript interpreter (may be null if not set).private DisplayData
static Ghostscript
Singleton access method.Singleton factory method for getting a Ghostscript,interpreter instance.static GhostscriptRevision
Gets Ghostscript revision data.Gets the error output stream of the Ghostscript interpreter (may be null if not set).getStdIn()
Gets the standard input stream of the Ghostscript interpreter (may be null if not set).Gets the standard output stream of the Ghostscript interpreter (may be null if not set).void
initialize
(String[] args) Initializes Ghostscript interpreter.void
Sends file Ghostscript interpreter.void
Sends command string to Ghostscript interpreter.void
setDisplayCallback
(DisplayCallback displayCallback) Sets a display callback for the Ghostscript interpreter.void
setStdErr
(OutputStream stdErr) Sets the error output stream of the Ghostscript interpreter.void
setStdIn
(InputStream stdIn) Sets the standard input stream of the Ghostscript interpreter.void
setStdOut
(OutputStream stdOut) Sets the standard output stream of the Ghostscript interpreter.
-
Field Details
-
PROPERTY_NAME_ENCODING
Name of the system property used to set the encoding to use for stdin.- See Also:
-
nativeInstanceByRef
Holds Ghostscript interpreter native instance (C pointer). -
instance
Holds singleton instance. -
stdIn
Standard input stream. -
stdOut
Standard output stream. -
stdErr
Error output stream. -
displayCallback
Display callback used to handle display. -
displayData
Stores display data when working with display callback. -
nativeDisplayCallback
Holds the native display callback.
-
-
Constructor Details
-
Ghostscript
private Ghostscript()Private constructor.
-
-
Method Details
-
getInstance
Singleton access method.- Returns:
- The singleton instance.
-
getDisplayCallback
Gets the display callback set on the Ghostscript interpreter (may be null if not set).- Returns:
- The DisplayCallback or null
-
setDisplayCallback
Sets a display callback for the Ghostscript interpreter.- Parameters:
displayCallback
- DisplayCallback object
-
getStdErr
Gets the error output stream of the Ghostscript interpreter (may be null if not set).- Returns:
- The OutputStream or null
-
setStdErr
Sets the error output stream of the Ghostscript interpreter.- Parameters:
stdErr
- OutputStream object
-
getStdOut
Gets the standard output stream of the Ghostscript interpreter (may be null if not set).- Returns:
- The OutputStream or null
-
setStdOut
Sets the standard output stream of the Ghostscript interpreter.- Parameters:
stdOut
- OutputStream object
-
getStdIn
Gets the standard input stream of the Ghostscript interpreter (may be null if not set).- Returns:
- The InputStream or null
-
setStdIn
Sets the standard input stream of the Ghostscript interpreter.- Parameters:
stdIn
- InputStream object
-
getNativeInstanceByRef
private GhostscriptLibrary.gs_main_instance.ByReference getNativeInstanceByRef() throws GhostscriptExceptionSingleton factory method for getting a Ghostscript,interpreter instance. Only called from class itself.- Returns:
- Ghostscript instance.
- Throws:
GhostscriptException
-
getDisplayData
-
getRevision
Gets Ghostscript revision data.- Returns:
- Revision data.
-
initialize
Initializes Ghostscript interpreter.- Parameters:
args
- Interpreter parameters. Use the same as Ghostscript command line arguments.- Throws:
GhostscriptException
-
buildNativeDisplayCallback
private GhostscriptLibrary.display_callback_s buildNativeDisplayCallback(DisplayCallback displayCallback) throws GhostscriptException Builds a native display callback from a DisplayCallback object.- Parameters:
displayCallback
- DisplayCallback to use.- Returns:
- The created native display callback.
- Throws:
GhostscriptException
-
exit
Exits Ghostscript interpreter. Must be called after initialize.- Throws:
GhostscriptException
-
runString
Sends command string to Ghostscript interpreter. Must be called after initialize method.- Parameters:
string
- Command string- Throws:
GhostscriptException
-
runFile
Sends file Ghostscript interpreter. Must be called after initialize method.- Parameters:
fileName
- File name- Throws:
GhostscriptException
-
deleteInstance
Deletes the singleton instance of the Ghostscript object. This ensures that the native Ghostscrit interpreter instance is deleted. This method must be called if Ghostscript is not used anymore or maybe reinitialized.- Throws:
GhostscriptException
-