Package org.ghost4j

Class Ghostscript


  • public class Ghostscript
    extends java.lang.Object
    Class representing the Ghostscript interpreter.
    • Field Detail

      • PROPERTY_NAME_ENCODING

        public static final java.lang.String PROPERTY_NAME_ENCODING
        Name of the system property used to set the encoding to use for stdin.
        See Also:
        Constant Field Values
      • instance

        private static Ghostscript instance
        Holds singleton instance.
      • stdIn

        private static java.io.InputStream stdIn
        Standard input stream.
      • stdOut

        private static java.io.OutputStream stdOut
        Standard output stream.
      • stdErr

        private static java.io.OutputStream stdErr
        Error output stream.
      • displayCallback

        private static DisplayCallback displayCallback
        Display callback used to handle display.
      • displayData

        private static DisplayData displayData
        Stores display data when working with display callback.
    • Constructor Detail

      • Ghostscript

        private Ghostscript()
        Private constructor.
    • Method Detail

      • getInstance

        public static Ghostscript getInstance()
        Singleton access method.
        Returns:
        The singleton instance.
      • getDisplayCallback

        public DisplayCallback getDisplayCallback()
        Gets the display callback set on the Ghostscript interpreter (may be null if not set).
        Returns:
        The DisplayCallback or null
      • setDisplayCallback

        public void setDisplayCallback​(DisplayCallback displayCallback)
        Sets a display callback for the Ghostscript interpreter.
        Parameters:
        displayCallback - DisplayCallback object
      • getStdErr

        public java.io.OutputStream getStdErr()
        Gets the error output stream of the Ghostscript interpreter (may be null if not set).
        Returns:
        The OutputStream or null
      • setStdErr

        public void setStdErr​(java.io.OutputStream stdErr)
        Sets the error output stream of the Ghostscript interpreter.
        Parameters:
        stdErr - OutputStream object
      • getStdOut

        public java.io.OutputStream getStdOut()
        Gets the standard output stream of the Ghostscript interpreter (may be null if not set).
        Returns:
        The OutputStream or null
      • setStdOut

        public void setStdOut​(java.io.OutputStream stdOut)
        Sets the standard output stream of the Ghostscript interpreter.
        Parameters:
        stdOut - OutputStream object
      • getStdIn

        public java.io.InputStream getStdIn()
        Gets the standard input stream of the Ghostscript interpreter (may be null if not set).
        Returns:
        The InputStream or null
      • setStdIn

        public void setStdIn​(java.io.InputStream stdIn)
        Sets the standard input stream of the Ghostscript interpreter.
        Parameters:
        stdIn - InputStream object
      • getDisplayData

        private DisplayData getDisplayData()
      • getRevision

        public static GhostscriptRevision getRevision()
        Gets Ghostscript revision data.
        Returns:
        Revision data.
      • initialize

        public void initialize​(java.lang.String[] args)
                        throws GhostscriptException
        Initializes Ghostscript interpreter.
        Parameters:
        args - Interpreter parameters. Use the same as Ghostscript command line arguments.
        Throws:
        GhostscriptException
      • runString

        public void runString​(java.lang.String string)
                       throws GhostscriptException
        Sends command string to Ghostscript interpreter. Must be called after initialize method.
        Parameters:
        string - Command string
        Throws:
        GhostscriptException
      • runFile

        public void runFile​(java.lang.String fileName)
                     throws GhostscriptException
        Sends file Ghostscript interpreter. Must be called after initialize method.
        Parameters:
        fileName - File name
        Throws:
        GhostscriptException
      • deleteInstance

        public static void deleteInstance()
                                   throws GhostscriptException
        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