module HexaPDF:: Content:: Operator
This module contains the content operator implementations.
General Information¶ ↑
A PDF content streams consists of a series of instructions, operands followed by an operator name. Each operator has a specific function, for example, the ‘G’ operator sets the stroke color to the specified gray value.
Since HexaPDF
doesn’t have a content stream rendering facility, it is only interested in the effects an operator has on the graphics state. By calling the invoke method with a Processor
as first argument and the operands as the rest of the arguments, the operator can modify the graphics state as needed. This ensures internal consistency and correct operation.
Operator
objects are designed to be state-less. This means that the operands have to be passed as arguments to the methods that need them.
Operator
Implementations¶ ↑
HexaPDF
comes with operator implementations for all PDF operations. These operator implementations are derived from the BaseOperator
class which provides all needed methods.
In general, an operator implementation is an object that responds to the following methods:
- invoke(processor, *operands)
-
When an operator is invoked, it performs its job, e.g. changing the graphics state.
- serialize(serializer, *operands)
-
Returns the operator together with its operands in serialized form.
- name
-
Returns the name of the operator as String.
See: PDF2.0 s8, s9
Constants
- DEFAULT_OPERATORS¶
Mapping of operator names to their default operator implementations.