Documentation ¶
Overview ¶
Package ps implements various functionalities needed for handling Postscript for PDF uses, in particular for PDF function type 4.
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 ¶
ErrRangeCheck occurs when an input value is incorrect or within valid boundaeries.
ErrStackOverflow is due to a stack overflow.
ErrStackUnderflow is due to a stack underflow.
ErrTypeCheck is due to a type mismatch, typically when a type is expected as input but a different type is received instead.
ErrUndefinedResult occurs when the function does not have a result for given input parameters. An example is division by 0.
ErrUnsupportedOperand occurs when an unsupported operand is encountered.
Functions ¶
Types ¶
type PSBoolean ¶
type PSBoolean struct {
Val bool
}
PSBoolean represents a boolean value.
func MakeBool ¶
MakeBool returns a new PSBoolean object initialized with `val`.
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`.
func (*PSExecutor) Execute ¶
func (exec *PSExecutor) Execute(objects []PSObject) ([]PSObject, error)
Execute executes the program for an input parameters `objects` and returns a slice of output objects.
type PSInteger ¶
type PSInteger struct {
Val int
}
PSInteger represents an integer.
func MakeInteger ¶
MakeInteger returns a new PSInteger object initialized with `val`.
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) Exec ¶
Exec executes the operand `op` in the state specified by `stack`.
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) Append ¶
Append appends an object to the PSProgram.
func (*PSProgram) Exec ¶
Exec executes the program, typically leaving output values on the stack.
type PSReal ¶
type PSReal struct {
Val float64
}
PSReal represents a real number.
func MakeReal ¶
MakeReal returns a new PSReal object initialized with `val`.
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) Pop ¶
Pop pops an object from the top of the stack.
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.
func (*PSStack) Push ¶
Push pushes an object on top of the stack.