Module: HexaPDF::Content::Operator
- Defined in:
- lib/hexapdf/content/operator.rb
Overview
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
Defined Under Namespace
Classes: AppendRectangle, BaseOperator, BeginText, ClipPath, ConcatenateMatrix, CurveTo, CurveToNoFirstControlPoint, CurveToNoSecondControlPoint, EndPath, EndText, InlineImage, LineTo, MoveText, MoveTextAndSetLeading, MoveTextNextLine, MoveTextNextLineAndShowText, MoveTo, NoArgumentOperator, RestoreGraphicsState, SaveGraphicsState, SetCharacterSpacing, SetDeviceCMYKNonStrokingColor, SetDeviceCMYKStrokingColor, SetDeviceGrayNonStrokingColor, SetDeviceGrayStrokingColor, SetDeviceRGBNonStrokingColor, SetDeviceRGBStrokingColor, SetFontAndSize, SetGraphicsStateParameters, SetHorizontalScaling, SetLeading, SetLineCapStyle, SetLineDashPattern, SetLineJoinStyle, SetLineWidth, SetMiterLimit, SetNonStrokingColor, SetNonStrokingColorSpace, SetRenderingIntent, SetSpacingMoveTextNextLineAndShowText, SetStrokingColor, SetStrokingColorSpace, SetTextMatrix, SetTextRenderingMode, SetTextRise, SetWordSpacing, ShowText, ShowTextWithPositioning, SingleNumericArgumentOperator
Constant Summary collapse
- DEFAULT_OPERATORS =
Mapping of operator names to their default operator implementations.
{ BX: NoArgumentOperator.new('BX'), EX: NoArgumentOperator.new('EX'), q: SaveGraphicsState.new, Q: RestoreGraphicsState.new, cm: ConcatenateMatrix.new, w: SetLineWidth.new, J: SetLineCapStyle.new, j: SetLineJoinStyle.new, M: SetMiterLimit.new, d: SetLineDashPattern.new, ri: SetRenderingIntent.new, gs: SetGraphicsStateParameters.new, CS: SetStrokingColorSpace.new, cs: SetNonStrokingColorSpace.new, SC: SetStrokingColor.new('SC'), SCN: SetStrokingColor.new('SCN'), sc: SetNonStrokingColor.new('sc'), scn: SetNonStrokingColor.new('scn'), G: SetDeviceGrayStrokingColor.new, g: SetDeviceGrayNonStrokingColor.new, RG: SetDeviceRGBStrokingColor.new, rg: SetDeviceRGBNonStrokingColor.new, K: SetDeviceCMYKStrokingColor.new, k: SetDeviceCMYKNonStrokingColor.new, m: MoveTo.new, re: AppendRectangle.new, l: LineTo.new, c: CurveTo.new, v: CurveToNoFirstControlPoint.new, y: CurveToNoSecondControlPoint.new, h: NoArgumentOperator.new('h'), S: EndPath.new('S'), s: EndPath.new('s'), f: EndPath.new('f'), F: EndPath.new('F'), 'f*': EndPath.new('f*'), B: EndPath.new('B'), 'B*': EndPath.new('B*'), b: EndPath.new('b'), 'b*': EndPath.new('b*'), n: EndPath.new('n'), W: ClipPath.new('W'), 'W*': ClipPath.new('W*'), BI: InlineImage.new, BT: BeginText.new, ET: EndText.new, Tc: SetCharacterSpacing.new, Tw: SetWordSpacing.new, Tz: SetHorizontalScaling.new, TL: SetLeading.new, Tf: SetFontAndSize.new, Tr: SetTextRenderingMode.new, Ts: SetTextRise.new, Td: MoveText.new, TD: MoveTextAndSetLeading.new, Tm: SetTextMatrix.new, 'T*': MoveTextNextLine.new, Tj: ShowText.new, "'": MoveTextNextLineAndShowText.new, '"': SetSpacingMoveTextNextLineAndShowText.new, TJ: ShowTextWithPositioning.new, }