ErrRangeCheck occurs when an input value is incorrect or within valid boundaeries.
var ErrRangeCheck = errors.New("range check error")
ErrStackOverflow is due to a stack overflow.
var ErrStackOverflow = errors.New("stack overflow")
ErrStackUnderflow is due to a stack underflow.
var ErrStackUnderflow = errors.New("stack underflow")
ErrTypeCheck is due to a type mismatch, typically when a type is expected as input but a different type is received instead.
var ErrTypeCheck = errors.New("type check error")
ErrUndefinedResult occurs when the function does not have a result for given input parameters. An example is division by 0.
var ErrUndefinedResult = errors.New("undefined result error")
ErrUnsupportedOperand occurs when an unsupported operand is encountered.
var ErrUnsupportedOperand = errors.New("unsupported operand")
func PSObjectArrayToFloat64Array(objects []PSObject) ([]float64, error)
PSObjectArrayToFloat64Array converts []PSObject into a []float64 array. Each PSObject must represent a number, otherwise a ErrTypeCheck error occurs.
PSBoolean represents a boolean value.
type PSBoolean struct { Val bool }
func MakeBool(val bool) *PSBoolean
MakeBool returns a new PSBoolean object initialized with `val`.
func (bool *PSBoolean) DebugString() string
func (bool *PSBoolean) Duplicate() PSObject
func (bool *PSBoolean) String() string
PSExecutor has its own execution stack and is used to executre a PS routine (program).
type PSExecutor struct { Stack *PSStack // contains filtered or unexported fields }
func NewPSExecutor(program *PSProgram) *PSExecutor
NewPSExecutor returns an initialized PSExecutor for an input `program`.
func (exec *PSExecutor) Execute(objects []PSObject) ([]PSObject, error)
Execute executes the program for an input parameters `objects` and returns a slice of output objects.
PSInteger represents an integer.
type PSInteger struct { Val int }
func MakeInteger(val int) *PSInteger
MakeInteger returns a new PSInteger object initialized with `val`.
func (int *PSInteger) DebugString() string
func (int *PSInteger) Duplicate() PSObject
func (int *PSInteger) String() string
PSObject represents a postscript object.
type PSObject interface { // Duplicate makes a fresh copy of the PSObject. Duplicate() PSObject // DebugString returns a descriptive representation of the PSObject with more information than String() // for debugging purposes. DebugString() string // String returns a string representation of the PSObject. String() string }
PSOperand represents a Postscript operand (text string).
type PSOperand string
func MakeOperand(val string) *PSOperand
MakeOperand returns a new PSOperand object based on string `val`.
func (op *PSOperand) DebugString() string
func (op *PSOperand) Duplicate() PSObject
func (op *PSOperand) Exec(stack *PSStack) error
Exec executes the operand `op` in the state specified by `stack`.
func (op *PSOperand) String() string
PSParser is a basic Postscript parser.
type PSParser struct {
// contains filtered or unexported fields
}
func NewPSParser(content []byte) *PSParser
NewPSParser returns a new instance of the PDF Postscript parser from input data.
func (p *PSParser) Parse() (*PSProgram, error)
Parse parses the postscript and store as a program that can be executed.
PSProgram defines a Postscript program which is a series of PS objects (arguments, commands, programs etc).
type PSProgram []PSObject
func NewPSProgram() *PSProgram
NewPSProgram returns an empty, initialized PSProgram.
func (prog *PSProgram) Append(obj PSObject)
Append appends an object to the PSProgram.
func (prog *PSProgram) DebugString() string
func (prog *PSProgram) Duplicate() PSObject
func (prog *PSProgram) Exec(stack *PSStack) error
Exec executes the program, typically leaving output values on the stack.
func (prog *PSProgram) String() string
PSReal represents a real number.
type PSReal struct { Val float64 }
func MakeReal(val float64) *PSReal
MakeReal returns a new PSReal object initialized with `val`.
func (real *PSReal) DebugString() string
func (real *PSReal) Duplicate() PSObject
func (real *PSReal) String() string
PSStack defines a stack of PSObjects. PSObjects can be pushed on or pull from the stack.
type PSStack []PSObject
func NewPSStack() *PSStack
NewPSStack returns an initialized PSStack.
func (stack *PSStack) DebugString() string
DebugString returns a descriptive string representation of the stack - intended for debugging.
func (stack *PSStack) Empty()
Empty empties the stack.
func (stack *PSStack) Pop() (PSObject, error)
Pop pops an object from the top of the stack.
func (stack *PSStack) PopInteger() (int, error)
PopInteger specificially pops an integer from the top of the stack, returning the value as an int.
func (stack *PSStack) PopNumberAsFloat64() (float64, error)
PopNumberAsFloat64 pops and return the numeric value of the top of the stack as a float64. Real or integer only.
func (stack *PSStack) Push(obj PSObject) error
Push pushes an object on top of the stack.
func (stack *PSStack) String() string
String returns a string representation of the stack.