PDF-Content-raku

[Raku PDF Project] / [PDF-Content Module] / PDF::Content :: Ops

class PDF::Content::Ops

A graphics machine for building and interpeting PDF Content operator streams

Description

The PDF::Content::Ops role implements methods and mnemonics for the full operator table, as defined in specification [PDF 1.7 Appendix A]:

* Operator * *Mnemonic* *Operands* *Description*
b CloseFillStroke Close, fill, and stroke path using nonzero winding number rule
B FillStroke Fill and stroke path using nonzero winding number rule
b* CloseEOFillStroke Close, fill, and stroke path using even-odd rule
B* EOFillStroke Fill and stroke path using even-odd rule
BDC BeginMarkedContentDict tag properties (PDF 1.2) Begin marked-content sequence with property list
BI BeginImage Begin inline image object
BMC BeginMarkedContent tag (PDF 1.2) Begin marked-content sequence
BT BeginText Begin text object
BX BeginExtended (PDF 1.1) Begin compatibility section
c CurveTo x1 y1 x2 y2 x3 y3 Append curved segment to path (two control points)
cm ConcatMatrix a b c d e f Concatenate matrix to current transformation matrix
CS SetStrokeColorSpace name (PDF 1.1) Set color space for stroking operations
cs SetFillColorSpace name (PDF 1.1) Set color space for nonstroking operations
d SetDashPattern dashArray dashPhase Set line dash pattern
d0 SetCharWidth wx wy Set glyph width in Type 3 font
d1 SetCharWidthBBox wx wy llx lly urx ury Set glyph width and bounding box in Type 3 font
Do XObject name Invoke named XObject
DP MarkPointDict tag properties (PDF 1.2) Define marked-content point with property list
EI EndImage End inline image object
EMC EndMarkedContent (PDF 1.2) End marked-content sequence
ET EndText End text object
EX EndExtended (PDF 1.1) End compatibility section
f Fill Fill path using nonzero winding number rule
F FillObsolete Fill path using nonzero winding number rule (obsolete)
f* EOFill Fill path using even-odd rule
G SetStrokeGray gray Set gray level for stroking operations
g SetFillGray gray Set gray level for nonstroking operations
gs SetGraphicsState dictName (PDF 1.2) Set parameters from graphics state parameter dictionary
h ClosePath Close subpath
i SetFlatness flatness Set flatness tolerance
ID ImageData Begin inline image data
j SetLineJoin lineJoin| Set line join style
J SetLineCap lineCap Set line cap style
K SetStrokeCMYK c m y k Set CMYK color for stroking operations
k SetFillCMYK c m y k Set CMYK color for nonstroking operations
l LineTo x y Append straight line segment to path
m MoveTo x y Begin new subpath
M SetMiterLimit miterLimit Set miter limit
MP MarkPoint tag (PDF 1.2) Define marked-content point
n EndPath End path without filling or stroking
q Save Save graphics state
Q Restore Restore graphics state
re Rectangle x y width height Append rectangle to path
RG SetStrokeRGB r g b Set RGB color for stroking operations
rg SetFillRGB r g b Set RGB color for nonstroking operations
ri SetRenderingIntent intent Set color rendering intent
s CloseStroke Close and stroke path
S Stroke Stroke path
SC SetStrokeColor c1 … cn (PDF 1.1) Set color for stroking operations
sc SetFillColor c1 … cn (PDF 1.1) Set color for nonstroking operations
SCN SetStrokeColorN c1 … cn [name] (PDF 1.2) Set color for stroking operations (ICCBased and special color spaces)
scn SetFillColorN c1 … cn [name] (PDF 1.2) Set color for nonstroking operations (ICCBased and special color spaces)
sh ShFill name (PDF 1.3) Paint area defined by shading pattern
T* TextNextLine Move to start of next text line
Tc SetCharSpacing| charSpace Set character spacing
Td TextMove tx ty Move text position
TD TextMoveSet tx ty Move text position and set leading
Tf SetFont font size Set text font and size
Tj ShowText string Show text
TJ ShowSpaceText array Show text, allowing individual glyph positioning
TL SetTextLeading leading Set text leading
Tm SetTextMatrix a b c d e f Set text matrix and text line matrix
Tr SetTextRender render Set text rendering mode
Ts SetTextRise rise Set text rise
Tw SetWordSpacing wordSpace Set word spacing
Tz SetHorizScaling scale Set horizontal text scaling
v CurveToInitial x2 y2 x3 y3 Append curved segment to path (initial point replicated)
w SetLineWidth lineWidth Set line width
W Clip Set clipping path using nonzero winding number rule
W* EOClip Set clipping path using even-odd rule
y CurveToFinal x1 y1 x3 y3 Append curved segment to path (final point replicated)
' MoveShowText string Move to next line and show text
" MoveSetShowText aw ac string Set word and character spacing, move to next line, and show text

head

Methods

method font-face

method font-face() returns PDF::COS::Dict

returns the current graphics font dictionary resource

method font-size

method font-size() returns Numeric

returns the current graphics font size

method tags

method tags() returns PDF::Content::Tag::NodeSet

returns the current tags status

multi method gsaves

multi method gsaves(
    :$delta! where { ... }
) returns Array

return graphics gsave stack, including changed variables only

multi method gsaves

multi method gsaves() returns Array

return graphics gsave stack, including all graphics variables

multi method graphics-state

multi method graphics-state(
    :$delta!
) returns Hash

return locally updated graphics state variables

multi method graphics-state

multi method graphics-state() returns Mu

return all current graphics state variables

method current-point

method current-point() returns PDF::Content::Ops::Vector

return current point

This method is only valid in a path context

multi method op

multi method op(
    Pair $_ where { ... }
) returns Mu

process operator quarantined by PDF::Grammar::Content / PDF::Native::COS as either an unknown operator or having an incorrect argument list

multi method op

multi method op(
    *@args is copy
) returns Mu

Process a parsed graphics operation

multi method ops

multi method ops(
    Str $ops
) returns Array

Parse and process graphics operations

multi method ops

multi method ops(
    List $ops?
) returns Array

Parse and process a list of graphics operations

method add-comment

method add-comment(
    Str $_
) returns Mu

Add a comment to the content stream

multi sub parse-content

multi sub parse-content(
    Str $content where { ... }
) returns Mu

parse, but don’t process PDF content operators

method finish

method finish() returns Mu

Finish a content stream

has Str $!content-cache

serialize content into a string. indent blocks for readability

method content-dump

method content-dump() returns Seq

serialized current content as a sequence of strings - for debugging/testing

method FALLBACK

method FALLBACK(
    $method,
    |c
) returns Mu

Treat operator mnemonics as methods