ghostscript

package
v0.0.0-...-e51bdc0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package ghostscript provides simple, and idiomatic Go bindings for the Ghostscript Interpreter C API. For more information: http://www.ghostscript.com/doc/current/API.htm

Index

Constants

View Source
const (
	MAX_SUPPORTED_REVISION = 9540
	MIN_SUPPORTED_REVISION = 910
	GS_NO_ERRORS           = 0
	GS_FATAL_ERROR         = C.e_Fatal
)

Variables

This section is empty.

Functions

func CStrings

func CStrings(goStrings []string) **C.char

CStrings converts a Go string array to a C array of char pointers, and returns a pointer to that array. It will allocate a new string array of the appropriate length, and should be garbage collected using FreeCStrings.

func FreeCStrings

func FreeCStrings(cStrings **C.char, length int)

FreeCStrings frees memory used to allocate a C array of char pointers.

func IsInstantiated

func IsInstantiated() bool

IsInstantiated returns true if a global static instance of Ghostscript already exists. This should be used to ensure that only one instance of Ghostscript may exist at any time. Ghostscript does not support multiple instances.

Types

type Ghostscript

type Ghostscript struct {
	// contains filtered or unexported fields
}

Ghostscript contains a pointer to the global static instance of Ghostscript. It should not be initialised manually. i.e. Call NewInstance instead. Only one instance of Ghostscript may exist at any time.

func NewInstance

func NewInstance() (*Ghostscript, error)

NewInstance is an implementation of gsapi_new_instance. It returns a global static instance of Ghostscript (encapsulated in a struct). i.e. Do not call NewInstance more than once, otherwise an error will be returned.

func (*Ghostscript) Destroy

func (gs *Ghostscript) Destroy()

Destroy is an implementation of gsapi_delete_instance. It destroys a global static instance of Ghostscript. It should be called only after Exit has been called if Init has been called.

func (*Ghostscript) Exit

func (gs *Ghostscript) Exit() error

Exit is an implementation of gsapi_exit. It exits the Ghostscript interpreter. It must be called if Init has been called, and just before Destroy.

func (*Ghostscript) Init

func (gs *Ghostscript) Init(args []string) error

Init is an implementation of gsapi_init_with_args. It initialises the Ghostscript interpreter given a set of arguments. The first argument is ignored, and the arguments that will be used starts from index 1.

func (*Ghostscript) RunOnFile

func (gs *Ghostscript) RunOnFile(fnDoc string) error

RunOnFile is an implementation of gsapi_run_file. It runs the Ghostscript interpreter against an existing file, given its name / path.

func (*Ghostscript) RunOnString

func (gs *Ghostscript) RunOnString(strDoc string) error

RunOnString is an implementation of gsapi_run_string_with_length. It runs the Ghostscript interpreter against a document in the form of a fixed length string.

type Revision

type Revision struct {
	Product      string
	Copyright    string
	Revision     int
	RevisionDate int
}

Revision contains information about the Ghostscript interpreter.

func GetRevision

func GetRevision() (Revision, error)

GetRevision is an implementation of gsapi_revision. It returns the version numbers, and strings of the Ghostscript interpreter. It is safe to call at any time, and it does not rely on an instance of Ghostscript. It should be called before any other interpreter library functions to ensure that the correct version of Ghostscript interpreter has been loaded.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL