Skip to main content

PdfText

Struct PdfText 

Source
pub struct PdfText {
    pub id: ElementId,
    pub content: TextContent,
    pub path: ElementPath,
}
Expand description

Strongly-typed text element with DOM capabilities.

Fields§

§id: ElementId§content: TextContent§path: ElementPath

Implementations§

Source§

impl PdfText

Source

pub fn id(&self) -> ElementId

Source

pub fn text(&self) -> &str

Source

pub fn bbox(&self) -> Rect

Source

pub fn font_name(&self) -> &str

Source

pub fn font_size(&self) -> f32

Source

pub fn is_bold(&self) -> bool

Source

pub fn is_italic(&self) -> bool

Source

pub fn color(&self) -> Color

Source

pub fn set_text(&mut self, new_text: impl Into<String>)

Set text content (fluent API).

Source

pub fn set_style(&mut self, style: TextStyle)

Modify style (fluent API).

Source

pub fn value(&self) -> &str

Get text content (alias for text(), Python-friendly).

Source

pub fn set_value(&mut self, new_text: impl Into<String>)

Set text content (alias for set_text(), Python-friendly).

Source

pub fn append(&mut self, text: &str)

Append text to the current content.

§Example
let mut text = page.find_text_containing("Hello").first().unwrap();
text.append(" World!");
// text is now "Hello World!"
Source

pub fn replace(&mut self, old: &str, new: &str) -> usize

Replace all occurrences of old with new in the text.

Returns the number of replacements made.

§Example
let mut text = page.find_text_containing("foo").first().unwrap();
let count = text.replace("foo", "bar");
println!("Replaced {} occurrences", count);
Source

pub fn clear(&mut self)

Clear the text content.

§Example
let mut text = page.find_text_containing("remove me").first().unwrap();
text.clear();
// text is now ""
Source

pub fn is_empty(&self) -> bool

Check if the text is empty.

Source

pub fn len(&self) -> usize

Get the length of the text in bytes.

Source

pub fn contains(&self, needle: &str) -> bool

Check if the text contains a substring.

Source

pub fn starts_with(&self, prefix: &str) -> bool

Check if the text starts with a prefix.

Source

pub fn ends_with(&self, suffix: &str) -> bool

Check if the text ends with a suffix.

Source

pub fn origin(&self) -> Option<Point>

Get the baseline origin point if available.

Source

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

Get the rotation angle in degrees if available.

Source

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

Get the rotation angle in radians if available.

Source

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

Get the transformation matrix [a, b, c, d, e, f] if available.

Source

pub fn is_rotated(&self) -> bool

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

Source

pub fn set_matrix(&mut self, matrix: [f32; 6])

Set the transformation matrix.

Source

pub fn set_origin(&mut self, origin: Point)

Set the origin point.

Source

pub fn set_rotation(&mut self, degrees: f32)

Set the rotation angle in degrees.

Trait Implementations§

Source§

impl Clone for PdfText

Source§

fn clone(&self) -> PdfText

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 PdfText

Source§

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

Formats the value using the given formatter. 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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> Ungil for T
where T: Send,