Skip to main content

PdfStyledString

Struct PdfStyledString 

Source
pub struct PdfStyledString<'a> { /* private fields */ }
Expand description

A single styled string in a PdfParagraph.

Implementations§

Source§

impl<'a> PdfStyledString<'a>

Source

pub fn new(text: String, font: &'a PdfFont<'a>, font_size: PdfPoints) -> Self

Creates a new PdfStyledString from the given arguments.

Source

pub fn from_text_object(text_object: &'a PdfPageTextObject<'a>) -> Self

Creates a new PdfStyledString from the given PdfPageTextObject.

Source

pub fn text(&self) -> &str

Returns the text in this PdfStyledString.

Source

pub fn font(&self) -> &PdfFont<'_>

Returns the PdfFont used to style this PdfStyledString.

Source

pub fn font_size(&self) -> PdfPoints

Returns the font size used to style this PdfStyledString.

Source

pub fn does_match_string_styling(&self, other: &PdfStyledString<'_>) -> bool

Returns true if the font and font size of this PdfStyledString is the same as that of the given string.

Source

pub fn does_match_object_styling(&self, other: &PdfPageTextObject<'_>) -> bool

Returns true if the font and font size of this PdfStyledString is the same as that of the given PdfPageTextObject.

Source

pub fn is_bold(&self) -> bool

Returns true if this styled string’s font is bold.

Checks the font descriptor’s force-bold flag, the font weight (>= 700), and the font family name for “bold” substring.

Source

pub fn is_italic(&self) -> bool

Returns true if this styled string’s font is italic.

Checks the font descriptor’s italic flag and the font family name for “italic” or “oblique” substrings.

Source

pub fn is_monospace(&self) -> bool

Returns true if this styled string’s font is monospace.

Checks the font descriptor’s fixed-pitch flag and the font family name against common monospace font patterns.

Source

pub fn as_text_object( &self, document: &PdfDocument<'a>, ) -> Result<PdfPageTextObject<'a>, PdfiumError>

Creates a new PdfPageTextObject from this styled string, using the Pdfium bindings in the given document.

Auto Trait Implementations§

§

impl<'a> !Freeze for PdfStyledString<'a>

§

impl<'a> !RefUnwindSafe for PdfStyledString<'a>

§

impl<'a> !Send for PdfStyledString<'a>

§

impl<'a> !Sync for PdfStyledString<'a>

§

impl<'a> !UnwindSafe for PdfStyledString<'a>

§

impl<'a> Unpin for PdfStyledString<'a>

§

impl<'a> UnsafeUnpin for PdfStyledString<'a>

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> 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, 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.