Documentation
¶
Overview ¶
Package ps implements various functionalities needed for handling Postscript for PDF uses, in particular for PDF function type 4.
Index ¶
- Variables
- func PSObjectArrayToFloat64Array(objects []PSObject) ([]float64, error)
- type PSBoolean
- type PSExecutor
- type PSInteger
- type PSObject
- type PSOperand
- type PSParser
- type PSProgram
- type PSReal
- type PSStack
- func (stack *PSStack) DebugString() string
- func (stack *PSStack) Empty()
- func (stack *PSStack) Pop() (PSObject, error)
- func (stack *PSStack) PopInteger() (int, error)
- func (stack *PSStack) PopNumberAsFloat64() (float64, error)
- func (stack *PSStack) Push(obj PSObject) error
- func (stack *PSStack) String() string
Constants ¶
This section is empty.
Variables ¶
var ErrRangeCheck = errors.New("range check error")
ErrRangeCheck occurs when an input value is incorrect or within valid boundaeries.
var ErrStackOverflow = errors.New("stack overflow")
ErrStackOverflow is due to a stack overflow.
var ErrStackUnderflow = errors.New("stack underflow")
ErrStackUnderflow is due to a stack underflow.
var ErrTypeCheck = errors.New("type check error")
ErrTypeCheck is due to a type mismatch, typically when a type is expected as input but a different type is received instead.
var ErrUndefinedResult = errors.New("undefined result error")
ErrUndefinedResult occurs when the function does not have a result for given input parameters. An example is division by 0.
var ErrUnsupportedOperand = errors.New("unsupported operand")
ErrUnsupportedOperand occurs when an unsupported operand is encountered.
Functions ¶
func PSObjectArrayToFloat64Array ¶
PSObjectArrayToFloat64Array converts []PSObject into a []float64 array. Each PSObject must represent a number, otherwise a ErrTypeCheck error occurs.
Types ¶
type PSBoolean ¶
type PSBoolean struct {
Val bool
}
PSBoolean represents a boolean value.
func (*PSBoolean) DebugString ¶
type PSExecutor ¶
type PSExecutor struct { Stack *PSStack // contains filtered or unexported fields }
PSExecutor has its own execution stack and is used to executre a PS routine (program).
func NewPSExecutor ¶
func NewPSExecutor(program *PSProgram) *PSExecutor
NewPSExecutor returns an initialized PSExecutor for an input `program`.
type PSInteger ¶
type PSInteger struct {
Val int
}
PSInteger represents an integer.
func MakeInteger ¶
MakeInteger returns a new PSInteger object initialized with `val`.
func (*PSInteger) DebugString ¶
type PSObject ¶
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 }
PSObject represents a postscript object.
type PSOperand ¶
type PSOperand string
PSOperand represents a Postscript operand (text string).
func MakeOperand ¶
MakeOperand returns a new PSOperand object based on string `val`.
func (*PSOperand) DebugString ¶
type PSParser ¶
type PSParser struct {
// contains filtered or unexported fields
}
PSParser is a basic Postscript parser.
func NewPSParser ¶
NewPSParser returns a new instance of the PDF Postscript parser from input data.
type PSProgram ¶
type PSProgram []PSObject
PSProgram defines a Postscript program which is a series of PS objects (arguments, commands, programs etc).
func NewPSProgram ¶
func NewPSProgram() *PSProgram
NewPSProgram returns an empty, initialized PSProgram.
func (*PSProgram) DebugString ¶
type PSReal ¶
type PSReal struct {
Val float64
}
PSReal represents a real number.
func (*PSReal) DebugString ¶
type PSStack ¶
type PSStack []PSObject
PSStack defines a stack of PSObjects. PSObjects can be pushed on or pull from the stack.
func (*PSStack) DebugString ¶
DebugString returns a descriptive string representation of the stack - intended for debugging.
func (*PSStack) PopInteger ¶
PopInteger specificially pops an integer from the top of the stack, returning the value as an int.
func (*PSStack) PopNumberAsFloat64 ¶
PopNumberAsFloat64 pops and return the numeric value of the top of the stack as a float64. Real or integer only.