ContentOperation

Enum ContentOperation 

Source
pub enum ContentOperation {
Show 67 variants BeginText, EndText, SetCharSpacing(f32), SetWordSpacing(f32), SetHorizontalScaling(f32), SetLeading(f32), SetFont(String, f32), SetTextRenderMode(i32), SetTextRise(f32), MoveText(f32, f32), MoveTextSetLeading(f32, f32), SetTextMatrix(f32, f32, f32, f32, f32, f32), NextLine, ShowText(Vec<u8>), ShowTextArray(Vec<TextElement>), NextLineShowText(Vec<u8>), SetSpacingNextLineShowText(f32, f32, Vec<u8>), SaveGraphicsState, RestoreGraphicsState, SetTransformMatrix(f32, f32, f32, f32, f32, f32), SetLineWidth(f32), SetLineCap(i32), SetLineJoin(i32), SetMiterLimit(f32), SetDashPattern(Vec<f32>, f32), SetIntent(String), SetFlatness(f32), SetGraphicsStateParams(String), MoveTo(f32, f32), LineTo(f32, f32), CurveTo(f32, f32, f32, f32, f32, f32), CurveToV(f32, f32, f32, f32), CurveToY(f32, f32, f32, f32), ClosePath, Rectangle(f32, f32, f32, f32), Stroke, CloseStroke, Fill, FillEvenOdd, FillStroke, FillStrokeEvenOdd, CloseFillStroke, CloseFillStrokeEvenOdd, EndPath, Clip, ClipEvenOdd, SetStrokingColorSpace(String), SetNonStrokingColorSpace(String), SetStrokingColor(Vec<f32>), SetNonStrokingColor(Vec<f32>), SetStrokingGray(f32), SetNonStrokingGray(f32), SetStrokingRGB(f32, f32, f32), SetNonStrokingRGB(f32, f32, f32), SetStrokingCMYK(f32, f32, f32, f32), SetNonStrokingCMYK(f32, f32, f32, f32), ShadingFill(String), BeginInlineImage, InlineImage { params: HashMap<String, Object>, data: Vec<u8>, }, PaintXObject(String), BeginMarkedContent(String), BeginMarkedContentWithProps(String, HashMap<String, String>), EndMarkedContent, DefineMarkedContentPoint(String), DefineMarkedContentPointWithProps(String, HashMap<String, String>), BeginCompatibility, EndCompatibility,
}
Expand description

Represents a single operator in a PDF content stream.

Each variant corresponds to a specific PDF operator and carries the associated operands. These operations form a complete instruction set for rendering PDF content.

§Categories

Operations are grouped into several categories:

  • Text Object: BeginText, EndText
  • Text State: Font, spacing, scaling, rendering mode
  • Text Positioning: Matrix transforms, moves, line advances
  • Text Showing: Display text with various formatting
  • Graphics State: Save/restore, transforms, line properties
  • Path Construction: Move, line, curve, rectangle operations
  • Path Painting: Stroke, fill, clipping operations
  • Color: RGB, CMYK, grayscale, and color space operations
  • XObject: External graphics and form placement
  • Marked Content: Semantic tagging for accessibility

§Example

use oxidize_pdf::parser::content::{ContentOperation};

// Text operation
let op1 = ContentOperation::ShowText(b"Hello".to_vec());

// Graphics operation
let op2 = ContentOperation::SetLineWidth(2.0);

// Path operation
let op3 = ContentOperation::Rectangle(10.0, 10.0, 100.0, 50.0);

Variants§

§

BeginText

Begin a text object (BT operator). All text showing operations must occur within a text object.

§

EndText

End a text object (ET operator). Closes the current text object started with BeginText.

§

SetCharSpacing(f32)

Set character spacing (Tc operator). Additional space between characters in unscaled text units.

§

SetWordSpacing(f32)

Set word spacing (Tw operator). Additional space for ASCII space character (0x20) in unscaled text units.

§

SetHorizontalScaling(f32)

Set horizontal text scaling (Tz operator). Percentage of normal width (100 = normal).

§

SetLeading(f32)

Set text leading (TL operator). Vertical distance between baselines for T* operator.

§

SetFont(String, f32)

Set font and size (Tf operator). Font name must match a key in the Resources/Font dictionary.

§

SetTextRenderMode(i32)

Set text rendering mode (Tr operator). 0=fill, 1=stroke, 2=fill+stroke, 3=invisible, 4=fill+clip, 5=stroke+clip, 6=fill+stroke+clip, 7=clip

§

SetTextRise(f32)

Set text rise (Ts operator). Vertical displacement for superscripts/subscripts in text units.

§

MoveText(f32, f32)

Move text position (Td operator). Translates the text matrix by (tx, ty).

§

MoveTextSetLeading(f32, f32)

Move text position and set leading (TD operator). Equivalent to: -ty TL tx ty Td

§

SetTextMatrix(f32, f32, f32, f32, f32, f32)

Set text matrix directly (Tm operator). Parameters: [a, b, c, d, e, f] for transformation matrix.

§

NextLine

Move to start of next line (T* operator). Uses the current leading value set with TL.

§

ShowText(Vec<u8>)

Show text string (Tj operator). The bytes are encoded according to the current font’s encoding.

§

ShowTextArray(Vec<TextElement>)

Show text with individual positioning (TJ operator). Array elements can be strings or position adjustments.

§

NextLineShowText(Vec<u8>)

Move to next line and show text (’ operator). Equivalent to: T* string Tj

§

SetSpacingNextLineShowText(f32, f32, Vec<u8>)

Set spacing, move to next line, and show text (“ operator). Equivalent to: word_spacing Tw char_spacing Tc string ’

§

SaveGraphicsState

Save current graphics state (q operator). Pushes the entire graphics state onto a stack.

§

RestoreGraphicsState

Restore graphics state (Q operator). Pops the graphics state from the stack.

§

SetTransformMatrix(f32, f32, f32, f32, f32, f32)

Concatenate matrix to current transformation matrix (cm operator). Modifies the CTM: CTM’ = CTM × [a b c d e f]

§

SetLineWidth(f32)

Set line width (w operator) in user space units.

§

SetLineCap(i32)

Set line cap style (J operator). 0=butt cap, 1=round cap, 2=projecting square cap

§

SetLineJoin(i32)

Set line join style (j operator). 0=miter join, 1=round join, 2=bevel join

§

SetMiterLimit(f32)

Set miter limit (M operator). Maximum ratio of miter length to line width.

§

SetDashPattern(Vec<f32>, f32)

Set dash pattern (d operator). Array of dash/gap lengths and starting phase.

§

SetIntent(String)

Set rendering intent (ri operator). Color rendering intent: /AbsoluteColorimetric, /RelativeColorimetric, /Saturation, /Perceptual

§

SetFlatness(f32)

Set flatness tolerance (i operator). Maximum error when rendering curves as line segments.

§

SetGraphicsStateParams(String)

Set graphics state from parameter dictionary (gs operator). References ExtGState resource dictionary.

§

MoveTo(f32, f32)

Begin new subpath at point (m operator).

§

LineTo(f32, f32)

Append straight line segment (l operator).

§

CurveTo(f32, f32, f32, f32, f32, f32)

Append cubic Bézier curve (c operator). Control points: (x1,y1), (x2,y2), endpoint: (x3,y3)

§

CurveToV(f32, f32, f32, f32)

Append cubic Bézier curve with first control point = current point (v operator).

§

CurveToY(f32, f32, f32, f32)

Append cubic Bézier curve with second control point = endpoint (y operator).

§

ClosePath

Close current subpath (h operator). Appends straight line to starting point.

§

Rectangle(f32, f32, f32, f32)

Append rectangle as complete subpath (re operator). Parameters: x, y, width, height

§

Stroke

Stroke the path (S operator).

§

CloseStroke

Close and stroke the path (s operator). Equivalent to: h S

§

Fill

Fill the path using nonzero winding rule (f or F operator).

§

FillEvenOdd

Fill the path using even-odd rule (f* operator).

§

FillStroke

Fill then stroke the path (B operator). Uses nonzero winding rule.

§

FillStrokeEvenOdd

Fill then stroke using even-odd rule (B* operator).

§

CloseFillStroke

Close, fill, and stroke the path (b operator). Equivalent to: h B

§

CloseFillStrokeEvenOdd

Close, fill, and stroke using even-odd rule (b* operator).

§

EndPath

End path without filling or stroking (n operator). Used primarily before clipping.

§

Clip

§

ClipEvenOdd

§

SetStrokingColorSpace(String)

Set stroking color space (CS operator). References ColorSpace resource dictionary.

§

SetNonStrokingColorSpace(String)

Set non-stroking color space (cs operator). References ColorSpace resource dictionary.

§

SetStrokingColor(Vec<f32>)

Set stroking color (SC, SCN operators). Number of components depends on current color space.

§

SetNonStrokingColor(Vec<f32>)

Set non-stroking color (sc, scn operators). Number of components depends on current color space.

§

SetStrokingGray(f32)

Set stroking color to DeviceGray (G operator). 0.0 = black, 1.0 = white

§

SetNonStrokingGray(f32)

Set non-stroking color to DeviceGray (g operator).

§

SetStrokingRGB(f32, f32, f32)

Set stroking color to DeviceRGB (RG operator). Components range from 0.0 to 1.0.

§

SetNonStrokingRGB(f32, f32, f32)

Set non-stroking color to DeviceRGB (rg operator).

§

SetStrokingCMYK(f32, f32, f32, f32)

Set stroking color to DeviceCMYK (K operator).

§

SetNonStrokingCMYK(f32, f32, f32, f32)

Set non-stroking color to DeviceCMYK (k operator).

§

ShadingFill(String)

§

BeginInlineImage

Begin inline image (BI operator)

§

InlineImage

Inline image with parsed dictionary and data

Fields

§params: HashMap<String, Object>

Image parameters (width, height, colorspace, etc.)

§data: Vec<u8>

Raw image data

§

PaintXObject(String)

Paint external object (Do operator). References XObject resource dictionary (images, forms).

§

BeginMarkedContent(String)

§

BeginMarkedContentWithProps(String, HashMap<String, String>)

§

EndMarkedContent

§

DefineMarkedContentPoint(String)

§

DefineMarkedContentPointWithProps(String, HashMap<String, String>)

§

BeginCompatibility

§

EndCompatibility

Trait Implementations§

Source§

impl Clone for ContentOperation

Source§

fn clone(&self) -> ContentOperation

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContentOperation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ContentOperation

Source§

fn eq(&self, other: &ContentOperation) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ContentOperation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more