Skip to main content

PathObject

Struct PathObject 

Source
pub struct PathObject {
Show 13 fields pub segments: Vec<PathSegment>, pub matrix: Matrix, pub fill_color: Option<Color>, pub stroke_color: Option<Color>, pub line_width: f32, pub line_cap: u8, pub line_join: u8, pub fill_mode: FillMode, pub dash_pattern: Option<DashPattern>, pub blend_mode: Option<BlendMode>, pub active: bool, pub marks: Vec<ContentMark>, pub clip_path: Option<ClipPath>,
}
Expand description

A path/shape object with fill and stroke properties.

Fields§

§segments: Vec<PathSegment>

Path segments.

§matrix: Matrix

Transformation matrix.

§fill_color: Option<Color>

Fill color (None = no fill).

§stroke_color: Option<Color>

Stroke color (None = no stroke).

§line_width: f32

Line width for stroking.

§line_cap: u8

Line cap style (0=butt, 1=round, 2=square).

§line_join: u8

Line join style (0=miter, 1=round, 2=bevel).

§fill_mode: FillMode

Fill mode.

§dash_pattern: Option<DashPattern>

Dash pattern for stroking (None = solid line).

Corresponds to FPDFPath_GetDashArray / FPDFPath_SetDashArray.

§blend_mode: Option<BlendMode>

Blend mode for compositing.

Corresponds to FPDFPageObj_GetBlendMode / FPDFPageObj_SetBlendMode.

§active: bool

Whether the object is active (visible).

Corresponds to FPDFPageObj_GetIsActive / FPDFPageObj_SetIsActive.

§marks: Vec<ContentMark>

Content marks attached to this object (for tagged PDF / accessibility).

Each mark corresponds to a BDCEMC pair wrapping this object in the content stream.

Corresponds to FPDFPageObj_CountMarks / FPDFPageObj_GetMark / etc.

§clip_path: Option<ClipPath>

Optional clipping path attached to this object.

Corresponds to FPDFPageObj_GetClipPath / FPDFPageObj_TransformClipPath.

Implementations§

Source§

impl PathObject

Source

pub fn set_fill_color(&mut self, color: Color)

Sets the fill color.

Corresponds to FPDFPageObj_SetFillColor.

Source

pub fn fill_color(&self) -> Option<&Color>

Returns the fill color, if set (upstream FPDFPageObj_GetFillColor).

Source

pub fn page_obj_get_fill_color(&self) -> Option<&Color>

Upstream-aligned alias for fill_color().

Corresponds to FPDFPageObj_GetFillColor.

Source

pub fn get_fill_color(&self) -> Option<&Color>

👎Deprecated:

use page_obj_get_fill_color() — matches upstream FPDFPageObj_GetFillColor

Non-upstream alias — use page_obj_get_fill_color().

Corresponds to FPDFPageObj_GetFillColor.

Source

pub fn set_stroke_color(&mut self, color: Color)

Sets the stroke color.

Corresponds to FPDFPageObj_SetStrokeColor.

Source

pub fn stroke_color(&self) -> Option<&Color>

Returns the stroke color, if set (upstream FPDFPageObj_GetStrokeColor).

Source

pub fn page_obj_get_stroke_color(&self) -> Option<&Color>

Upstream-aligned alias for stroke_color().

Corresponds to FPDFPageObj_GetStrokeColor.

Source

pub fn get_stroke_color(&self) -> Option<&Color>

👎Deprecated:

use page_obj_get_stroke_color() — matches upstream FPDFPageObj_GetStrokeColor

Non-upstream alias — use page_obj_get_stroke_color().

Corresponds to FPDFPageObj_GetStrokeColor.

Source

pub fn set_line_width(&mut self, width: f32)

Sets the stroke (line) width.

Corresponds to FPDFPageObj_SetStrokeWidth.

Source

pub fn page_obj_set_stroke_width(&mut self, width: f32)

Upstream-aligned alias for Self::set_line_width().

Corresponds to FPDFPageObj_SetStrokeWidth.

Source

pub fn set_stroke_width(&mut self, width: f32)

👎Deprecated:

use page_obj_set_stroke_width() — matches upstream FPDFPageObj_SetStrokeWidth

Non-upstream alias — use page_obj_set_stroke_width().

Corresponds to FPDFPageObj_SetStrokeWidth.

Source

pub fn line_width(&self) -> f32

Returns the stroke (line) width (upstream FPDFPageObj_GetStrokeWidth).

Source

pub fn get_line_width(&self) -> f32

👎Deprecated:

use page_obj_get_stroke_width() — matches upstream FPDFPageObj_GetStrokeWidth

Non-upstream alias — use page_obj_get_stroke_width().

There is no FPDFPageObj_GetLineWidth; the upstream function is FPDFPageObj_GetStrokeWidth.

Source

pub fn page_obj_get_stroke_width(&self) -> f32

Upstream-aligned alias for line_width().

Corresponds to FPDFPageObj_GetStrokeWidth.

Source

pub fn get_stroke_width(&self) -> f32

👎Deprecated:

use page_obj_get_stroke_width() — matches upstream FPDFPageObj_GetStrokeWidth

Non-upstream alias — use page_obj_get_stroke_width().

Corresponds to FPDFPageObj_GetStrokeWidth.

Source

pub fn set_line_join(&mut self, join: u8)

Sets the line join style (0=miter, 1=round, 2=bevel).

Corresponds to FPDFPageObj_SetLineJoin.

Source

pub fn line_join(&self) -> u8

Returns the line join style (upstream FPDFPageObj_GetLineJoin).

Source

pub fn page_obj_get_line_join(&self) -> u8

Upstream-aligned alias for line_join().

Corresponds to FPDFPageObj_GetLineJoin.

Source

pub fn get_line_join(&self) -> u8

👎Deprecated:

use page_obj_get_line_join() — matches upstream FPDFPageObj_GetLineJoin

Non-upstream alias — use page_obj_get_line_join().

Corresponds to FPDFPageObj_GetLineJoin.

Source

pub fn set_line_cap(&mut self, cap: u8)

Sets the line cap style (0=butt, 1=round, 2=square).

Corresponds to FPDFPageObj_SetLineCap.

Source

pub fn line_cap(&self) -> u8

Returns the line cap style (upstream FPDFPageObj_GetLineCap).

Source

pub fn page_obj_get_line_cap(&self) -> u8

Upstream-aligned alias for line_cap().

Corresponds to FPDFPageObj_GetLineCap.

Source

pub fn get_line_cap(&self) -> u8

👎Deprecated:

use page_obj_get_line_cap() — matches upstream FPDFPageObj_GetLineCap

Non-upstream alias — use page_obj_get_line_cap().

Corresponds to FPDFPageObj_GetLineCap.

Source

pub fn dash_pattern(&self) -> Option<&DashPattern>

Returns the current dash pattern, if any.

Corresponds to FPDFPath_GetDashArray + FPDFPath_GetDashPhase.

Source

pub fn set_dash_pattern(&mut self, pattern: Option<DashPattern>)

Sets or clears the dash pattern.

Pass None to revert to a solid stroke.

Corresponds to FPDFPath_SetDashArray.

Source

pub fn dash_phase(&self) -> f32

Returns the dash phase offset.

Returns 0.0 when no dash pattern is set.

Corresponds to FPDFPath_GetDashPhase.

Source

pub fn path_get_dash_phase(&self) -> f32

Upstream-aligned alias for dash_phase().

Corresponds to FPDFPath_GetDashPhase.

Source

pub fn get_dash_phase(&self) -> f32

👎Deprecated:

use path_get_dash_phase() — matches upstream FPDFPath_GetDashPhase

Non-upstream alias — use path_get_dash_phase().

Corresponds to FPDFPath_GetDashPhase.

Source

pub fn set_dash_phase(&mut self, phase: f32)

Sets the dash phase on the existing dash pattern.

If no dash pattern is set, this is a no-op.

Corresponds to FPDFPath_SetDashPhase.

Source

pub fn dash_count(&self) -> usize

Returns the number of elements in the dash array.

Returns 0 when no dash pattern is set.

Corresponds to FPDFPageObj_GetDashCount.

Source

pub fn page_obj_get_dash_count(&self) -> usize

Upstream-aligned alias for dash_count().

Corresponds to FPDFPageObj_GetDashCount.

Source

pub fn get_dash_count(&self) -> usize

👎Deprecated:

use page_obj_get_dash_count() — matches upstream FPDFPageObj_GetDashCount

Non-upstream alias — use page_obj_get_dash_count().

Corresponds to FPDFPageObj_GetDashCount.

Source

pub fn dash_array(&self) -> &[f32]

Returns the dash array (alternating dash/gap lengths).

Returns an empty slice when no dash pattern is set.

Corresponds to FPDFPath_GetDashArray.

Source

pub fn path_get_dash_array(&self) -> &[f32]

Upstream-aligned alias for dash_array().

Corresponds to FPDFPath_GetDashArray.

Source

pub fn get_dash_array(&self) -> &[f32]

👎Deprecated:

use path_get_dash_array() — matches upstream FPDFPath_GetDashArray

Non-upstream alias — use path_get_dash_array().

Corresponds to FPDFPath_GetDashArray.

Source

pub fn set_dash_array(&mut self, array: Vec<f32>, phase: f32)

Sets the dash array and phase, replacing any existing dash pattern.

Passing an empty array clears the dash pattern (solid line).

Corresponds to FPDFPath_SetDashArray.

Source

pub fn blend_mode(&self) -> Option<BlendMode>

Returns the blend mode for this object.

Corresponds to FPDFPageObj_GetBlendMode.

Source

pub fn page_obj_get_blend_mode(&self) -> Option<BlendMode>

Upstream-aligned alias for blend_mode().

Corresponds to FPDFPageObj_GetBlendMode.

Source

pub fn get_blend_mode(&self) -> Option<BlendMode>

👎Deprecated:

use page_obj_get_blend_mode() — matches upstream FPDFPageObj_GetBlendMode

Non-upstream alias — use page_obj_get_blend_mode().

Corresponds to FPDFPageObj_GetBlendMode.

Source

pub fn set_blend_mode(&mut self, mode: Option<BlendMode>)

Sets the blend mode for this object.

Corresponds to FPDFPageObj_SetBlendMode.

Source

pub fn mark_count(&self) -> usize

Return the number of content marks on this object.

Corresponds to FPDFPageObj_CountMarks.

Source

pub fn page_obj_count_marks(&self) -> usize

Upstream-aligned alias for mark_count().

Corresponds to FPDFPageObj_CountMarks.

Source

pub fn count_marks(&self) -> usize

👎Deprecated:

use page_obj_count_marks() — matches upstream FPDFPageObj_CountMarks

Non-upstream alias — use page_obj_count_marks().

Corresponds to FPDFPageObj_CountMarks.

Source

pub fn mark(&self, index: usize) -> Option<&ContentMark>

Return the content mark at the given index, or None if out of range.

Corresponds to FPDFPageObj_GetMark.

Source

pub fn page_obj_get_mark(&self, index: usize) -> Option<&ContentMark>

Upstream-aligned alias for mark().

Corresponds to FPDFPageObj_GetMark.

Source

pub fn get_mark(&self, index: usize) -> Option<&ContentMark>

👎Deprecated:

use page_obj_get_mark() — matches upstream FPDFPageObj_GetMark

Non-upstream alias — use page_obj_get_mark().

Corresponds to FPDFPageObj_GetMark.

Source

pub fn add_mark(&mut self, name: impl Into<String>) -> &mut ContentMark

Add a new content mark with the given name and return a mutable reference to it.

Corresponds to FPDFPageObj_AddMark.

Source

pub fn remove_mark(&mut self, index: usize) -> bool

Remove the content mark at the given index.

Returns true if the index was valid and the mark was removed, false if out of range.

Corresponds to FPDFPageObj_RemoveMark.

Source

pub fn marks(&self) -> &[ContentMark]

Return a slice of all content marks on this object.

Source

pub fn marked_content_id(&self) -> Option<i64>

Return the marked content ID (/MCID) from the first mark that has one, or None if no mark carries an MCID.

Corresponds to FPDFPageObj_GetMarkedContentID.

Source

pub fn page_obj_get_marked_content_id(&self) -> Option<i64>

Upstream-aligned alias for marked_content_id().

Corresponds to FPDFPageObj_GetMarkedContentID.

Source

pub fn get_marked_content_id(&self) -> Option<i64>

👎Deprecated:

use page_obj_get_marked_content_id() — matches upstream FPDFPageObj_GetMarkedContentID

Non-upstream alias — use page_obj_get_marked_content_id().

Corresponds to FPDFPageObj_GetMarkedContentID.

Source

pub fn has_transparency(&self) -> bool

Returns true if this path object has any transparency.

A path is considered transparent when it has a non-Normal blend mode.

Corresponds to FPDFPageObj_HasTransparency.

Source

pub fn is_transparent(&self) -> bool

👎Deprecated:

use has_transparency() — matches upstream FPDFPageObj_HasTransparency

Non-upstream convenience alias for has_transparency().

Prefer has_transparency(), which matches the upstream FPDFPageObj_HasTransparency name exactly.

Source

pub fn object_type(&self) -> u32

Returns the PDFium page-object-type constant for path objects: 2.

Corresponds to FPDFPageObj_GetType returning FPDF_PAGEOBJ_PATH.

Source

pub fn get_object_type(&self) -> u32

👎Deprecated:

use page_obj_get_type() — matches upstream FPDFPageObj_GetType

Non-upstream alias — use page_obj_get_type().

The actual upstream function is FPDFPageObj_GetType; there is no FPDFPageObj_GetObjectType.

Source

pub fn page_obj_get_type(&self) -> u32

Upstream-aligned alias for object_type().

Corresponds to FPDFPageObj_GetType.

Source

pub fn get_type(&self) -> u32

👎Deprecated:

use page_obj_get_type() — matches upstream FPDFPageObj_GetType

Source

pub fn transform(&mut self, matrix: &Matrix)

Applies a matrix transform to all path segments.

Each control point is transformed by matrix. For Rect segments, the origin is transformed and width/height are uniformly scaled.

Corresponds to FPDFPageObj_Transform.

Source

pub fn matrix(&self) -> Matrix

Returns the transformation matrix for this path object.

For path objects, coordinates are stored in page space (absolute), so this returns the identity matrix unless a matrix was explicitly assigned via the matrix field.

Corresponds to FPDFPageObj_GetMatrix.

Source

pub fn page_obj_get_matrix(&self) -> Matrix

Upstream-aligned alias for matrix().

Corresponds to FPDFPageObj_GetMatrix.

Source

pub fn get_matrix(&self) -> Matrix

👎Deprecated:

use page_obj_get_matrix() — matches upstream FPDFPageObj_GetMatrix

Source

pub fn segment_count(&self) -> usize

Returns the number of path segments in this path object.

Corresponds to FPDFPath_CountSegments.

Source

pub fn path_count_segments(&self) -> usize

Upstream-aligned alias for segment_count().

Corresponds to FPDFPath_CountSegments.

Source

pub fn count_segments(&self) -> usize

👎Deprecated:

use path_count_segments() — matches upstream FPDFPath_CountSegments

Source

pub fn draw_mode(&self) -> (FillMode, bool)

Returns the draw mode of this path object as (fill_mode, stroke).

fill_mode is the current FillMode; stroke is true when this path has a stroke color set.

Corresponds to FPDFPath_GetDrawMode.

Source

pub fn path_get_draw_mode(&self) -> (FillMode, bool)

Upstream-aligned alias for draw_mode().

Corresponds to FPDFPath_GetDrawMode.

Source

pub fn get_draw_mode(&self) -> (FillMode, bool)

👎Deprecated:

use path_get_draw_mode() — matches upstream FPDFPath_GetDrawMode

Source

pub fn set_draw_mode(&mut self, fill_mode: FillMode, stroke: bool)

Sets the draw mode of this path object.

fill_mode controls whether and how the path interior is filled. stroke controls whether a stroke color is retained; when false the existing stroke color is cleared.

Corresponds to FPDFPath_SetDrawMode.

Source

pub fn path_set_draw_mode(&mut self, fill_mode: FillMode, stroke: bool)

Upstream-aligned alias for set_draw_mode().

Corresponds to FPDFPath_SetDrawMode.

Source

pub fn fill_mode(&self) -> FillMode

Returns the fill mode for this path object.

Corresponds to the fillmode out-parameter of FPDFPath_GetDrawMode.

Source

pub fn set_fill_mode(&mut self, mode: FillMode)

Sets the fill mode for this path object.

Corresponds to the fillmode parameter of FPDFPath_SetDrawMode.

Source

pub fn is_stroked(&self) -> bool

Returns whether this path is stroked (i.e. has a stroke color set).

Corresponds to the stroke out-parameter of FPDFPath_GetDrawMode.

Source

pub fn bounds(&self) -> Option<Rect>

Corresponds to FPDFPageObj_GetBounds.

Source

pub fn segment(&self, index: usize) -> Option<&PathSegment>

Returns the path segment at index, or None if out of range.

Corresponds to FPDFPath_GetPathSegment.

Source

pub fn path_get_path_segment(&self, index: usize) -> Option<&PathSegment>

Upstream-aligned alias for segment().

Corresponds to FPDFPath_GetPathSegment.

Source

pub fn get_path_segment(&self, index: usize) -> Option<&PathSegment>

👎Deprecated:

use path_get_path_segment() — matches upstream FPDFPath_GetPathSegment

Source

pub fn create_at(x: f64, y: f64) -> Self

Creates a new path object with an initial MoveTo at (x, y).

The path starts with default stroke (black, 1pt) and no fill. Use the builder-style move_to, line_to, bezier_to, and close methods to append further segments.

Corresponds to FPDFPageObj_CreateNewPath(x, y).

Source

pub fn page_obj_create_new_path(x: f64, y: f64) -> Self

Upstream-aligned alias for create_at().

Corresponds to FPDFPageObj_CreateNewPath.

Source

pub fn create_rect(x: f64, y: f64, width: f64, height: f64) -> Self

Creates a new rectangular path object at (x, y) with width × height.

The rectangle is encoded as a closed Rect segment matching upstream CPDF_PathObject::AppendRect(x, y, x+w, y+h). Default stroke is black, 1pt; no fill is set.

Corresponds to FPDFPageObj_CreateNewRect(x, y, w, h).

Source

pub fn page_obj_create_new_rect(x: f64, y: f64, width: f64, height: f64) -> Self

Upstream-aligned alias for create_rect().

Corresponds to FPDFPageObj_CreateNewRect.

Source

pub fn move_to(&mut self, x: f64, y: f64) -> &mut Self

Append a MoveTo segment to this path.

Corresponds to FPDFPath_MoveTo.

Source

pub fn path_move_to(&mut self, x: f64, y: f64) -> &mut Self

Upstream-aligned alias for move_to().

Corresponds to FPDFPath_MoveTo.

Source

pub fn line_to(&mut self, x: f64, y: f64) -> &mut Self

Append a LineTo segment to this path.

Corresponds to FPDFPath_LineTo.

Source

pub fn path_line_to(&mut self, x: f64, y: f64) -> &mut Self

Upstream-aligned alias for line_to().

Corresponds to FPDFPath_LineTo.

Source

pub fn bezier_to( &mut self, x1: f64, y1: f64, x2: f64, y2: f64, x3: f64, y3: f64, ) -> &mut Self

Append a cubic Bézier curve segment to this path.

(x1, y1) and (x2, y2) are the control points; (x3, y3) is the end point.

Corresponds to FPDFPath_BezierTo.

Source

pub fn path_bezier_to( &mut self, x1: f64, y1: f64, x2: f64, y2: f64, x3: f64, y3: f64, ) -> &mut Self

Upstream-aligned alias for bezier_to().

Corresponds to FPDFPath_BezierTo.

Source

pub fn close(&mut self) -> &mut Self

Close the current subpath.

Corresponds to FPDFPath_Close.

Source

pub fn path_close(&mut self) -> &mut Self

Upstream-aligned alias for close().

Corresponds to FPDFPath_Close.

Trait Implementations§

Source§

impl Clone for PathObject

Source§

fn clone(&self) -> PathObject

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 PathObject

Source§

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

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

impl Default for PathObject

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Same for T

Source§

type Output = T

Should always be Self
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