Skip to main content

TextContent

Struct TextContent 

Source
pub struct TextContent {
    pub text: String,
    pub bbox: Rect,
    pub font: FontSpec,
    pub style: TextStyle,
    pub reading_order: Option<usize>,
    pub artifact_type: Option<ArtifactType>,
    pub origin: Option<Point>,
    pub rotation_degrees: Option<f32>,
    pub matrix: Option<[f32; 6]>,
}
Expand description

Text content that can be extracted from or written to a PDF.

This is the unified text representation for both reading and writing. Unlike TextSpan which is extraction-focused, TextContent is designed to work symmetrically for both directions.

Fields§

§text: String

The text string

§bbox: Rect

Bounding box of the text

§font: FontSpec

Font specification

§style: TextStyle

Text styling (bold, italic, color, etc.)

§reading_order: Option<usize>

Reading order index (for extraction) or write order (for generation)

§artifact_type: Option<ArtifactType>

Artifact type classification

§origin: Option<Point>

Baseline origin point (extracted from text matrix)

§rotation_degrees: Option<f32>

Rotation angle in degrees (0-360)

§matrix: Option<[f32; 6]>

Full transformation matrix [a, b, c, d, e, f]

Implementations§

Source§

impl TextContent

Source

pub fn new( text: impl Into<String>, bbox: Rect, font: FontSpec, style: TextStyle, ) -> Self

Create a new text content element.

Source

pub fn with_reading_order(self, order: usize) -> Self

Create text content with reading order.

Source

pub fn with_artifact_type(self, artifact_type: ArtifactType) -> Self

Set the artifact type.

Source

pub fn is_bold(&self) -> bool

Check if this text is bold.

Source

pub fn is_italic(&self) -> bool

Check if this text is italic.

Source

pub fn font_size(&self) -> f32

Get the font size in points.

Source

pub fn with_matrix(self, matrix: [f32; 6]) -> Self

Set the transformation matrix.

Source

pub fn with_origin(self, origin: Point) -> Self

Set the origin point.

Source

pub fn with_rotation(self, degrees: f32) -> Self

Set the rotation angle in degrees.

Source

pub fn is_rotated(&self) -> bool

Check if this text is rotated (non-zero rotation).

Source

pub fn rotation_radians(&self) -> Option<f32>

Get rotation angle in radians.

Source

pub fn get_matrix(&self) -> Option<[f32; 6]>

Get the transformation matrix if available.

Trait Implementations§

Source§

impl Clone for TextContent

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TextContent

Source§

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

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

impl Default for TextContent

Source§

fn default() -> Self

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

impl From<TextContent> for TextSpan

Convert from TextContent to TextSpan (for backward compatibility).

Source§

fn from(content: TextContent) -> Self

Converts to this type from the input type.
Source§

impl From<TextSpan> for TextContent

Convert from TextSpan (extraction result) to TextContent (unified representation).

Source§

fn from(span: TextSpan) -> Self

Converts to this type from the input type.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> ErasedDestructor for T
where T: 'static,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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