Skip to main content

TextObject

Struct TextObject 

Source
pub struct TextObject {
Show 13 fields pub font_name: Name, pub font_size: f32, pub matrix: Matrix, pub text: String, pub fill_color: Option<Color>, pub stroke_color: Option<Color>, pub rendering_mode: TextRenderingMode, pub char_spacing: f32, pub word_spacing: f32, pub blend_mode: Option<BlendMode>, pub active: bool, pub marks: Vec<ContentMark>, pub clip_path: Option<ClipPath>, /* private fields */
}
Expand description

A text object with font, position, and color.

Fields§

§font_name: Name

Font name (must match a resource font name).

§font_size: f32

Font size in points.

§matrix: Matrix

Transformation matrix (includes position).

§text: String

The text string to render.

§fill_color: Option<Color>

Fill color.

§stroke_color: Option<Color>

Stroke color.

§rendering_mode: TextRenderingMode

Text rendering mode.

§char_spacing: f32

Character spacing.

§word_spacing: f32

Word spacing.

§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 TextObject

Source

pub fn with_standard_font(font_name: &str, size: f32) -> Self

Create a text object using a Standard-14 font name.

This is a convenience constructor that sets the font name directly. For precise resource registration, prefer TextObject::with_font together with EditDocument::load_standard_font.

Corresponds to FPDFPageObj_NewTextObj.

Source

pub fn with_font(registration: &FontRegistration, size: f32) -> Self

Create a text object from a crate::font_reg::FontRegistration.

Sets font_object_id so that content-stream generation uses the exact PDF object ID of the registered font dictionary.

Corresponds to FPDFPageObj_CreateTextObj.

Source

pub fn from_font_registration( font_registration: &FontRegistration, font_size: f32, ) -> Self

👎Deprecated:

use with_font()from_font_registration is not an upstream FPDF name

Non-upstream alias — use with_font().

FPDFPageObj_CreateTextObj maps to create_text_obj; this name (from_font_registration) is not an upstream FPDF_* name.

Source

pub fn text(&self) -> &str

Return the text string stored in this object.

Corresponds to FPDFTextObj_GetText (without requiring a text_page).

Source

pub fn text_obj_get_text(&self) -> &str

Upstream-aligned alias for text().

Corresponds to FPDFTextObj_GetText.

Source

pub fn get_text(&self) -> &str

👎Deprecated:

use text_obj_get_text() — matches upstream FPDFTextObj_GetText

Source

pub fn font_size(&self) -> f32

Return the font size in points.

Corresponds to FPDFTextObj_GetFontSize.

Source

pub fn text_obj_get_font_size(&self) -> f32

Upstream-aligned alias for font_size().

Corresponds to FPDFTextObj_GetFontSize.

Source

pub fn get_font_size(&self) -> f32

👎Deprecated:

use text_obj_get_font_size() — matches upstream FPDFTextObj_GetFontSize

Source

pub fn rendering_mode(&self) -> TextRenderingMode

Return the text rendering mode.

Corresponds to FPDFTextObj_GetTextRenderMode.

Source

pub fn text_obj_get_text_render_mode(&self) -> TextRenderingMode

Upstream-aligned alias for rendering_mode().

Corresponds to FPDFTextObj_GetTextRenderMode.

Source

pub fn get_text_render_mode(&self) -> TextRenderingMode

👎Deprecated:

use text_obj_get_text_render_mode() — matches upstream FPDFTextObj_GetTextRenderMode

Source

pub fn font_name(&self) -> &Name

Return the font name as a PDF Name.

Corresponds to FPDFTextObj_GetFont (name only; for full font metrics use the rpdfium-font crate).

Source

pub fn text_obj_get_font(&self) -> &Name

Upstream-aligned alias for font_name().

Corresponds to FPDFTextObj_GetFont.

Source

pub fn get_font(&self) -> &Name

👎Deprecated:

use text_obj_get_font() — matches upstream FPDFTextObj_GetFont

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_font_size(&mut self, size: f32)

Sets the font size in points.

Corresponds to FPDFTextObj_SetFontSize (not a direct upstream function, but enables mutation after construction).

Source

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

Sets the text content of this text object.

Corresponds to FPDFTextObj_SetText.

Source

pub fn text_obj_set_text(&mut self, text: impl Into<String>)

Upstream-aligned alias for set_text().

Corresponds to FPDFTextObj_SetText.

Source

pub fn set_text_content(&mut self, text: String)

👎Deprecated:

use set_text() — matches upstream FPDFText_SetText

Non-upstream convenience alias for set_text().

Prefer set_text(), which matches the upstream FPDFText_SetText name exactly.

Source

pub fn set_rendering_mode(&mut self, mode: TextRenderingMode)

Sets the text rendering mode.

Corresponds to FPDFTextObj_SetTextRenderMode.

Source

pub fn text_obj_set_text_render_mode(&mut self, mode: TextRenderingMode)

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

Corresponds to FPDFTextObj_SetTextRenderMode.

Source

pub fn set_text_render_mode(&mut self, mode: TextRenderingMode)

👎Deprecated:

use text_obj_set_text_render_mode() — matches upstream FPDFTextObj_SetTextRenderMode

Non-upstream alias — use text_obj_set_text_render_mode().

Corresponds to FPDFTextObj_SetTextRenderMode.

Source

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

Applies a matrix transform by pre-multiplying into the object’s matrix.

Corresponds to FPDFPageObj_Transform.

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 text object has any transparency.

A text object 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 text objects: 1.

Corresponds to FPDFPageObj_GetType returning FPDF_PAGEOBJ_TEXT.

Source

pub fn get_object_type(&self) -> u32

👎Deprecated:

use page_obj_get_type() — matches upstream FPDFPageObj_GetType

Non-upstream alias — use 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 rotated_bounds(&self) -> Option<[Point; 4]>

Returns the tight rotated bounding quadrilateral for this text object as 4 corner points in page coordinates.

The corners are computed by transforming the unit square through the object’s text matrix, which encodes position, scale, and rotation.

Corresponds to FPDFPageObj_GetRotatedBounds.

Source

pub fn page_obj_get_rotated_bounds(&self) -> Option<[Point; 4]>

Upstream-aligned alias for rotated_bounds().

Corresponds to FPDFPageObj_GetRotatedBounds.

Source

pub fn get_rotated_bounds(&self) -> Option<[Point; 4]>

👎Deprecated:

use page_obj_get_rotated_bounds() — matches upstream FPDFPageObj_GetRotatedBounds

Non-upstream alias — use page_obj_get_rotated_bounds().

Corresponds to FPDFPageObj_GetRotatedBounds.

Source

pub fn set_char_codes(&mut self, codes: &[u32])

Sets text content from raw PDF character codes.

Unlike set_text() which takes a Unicode string, this takes PDF-specific character codes directly. Each code is converted to a Unicode scalar value if valid, or the replacement character (U+FFFD) otherwise.

Corresponds to FPDFText_SetCharcodes.

Source

pub fn text_set_charcodes(&mut self, codes: &[u32])

Upstream-aligned alias for set_char_codes().

Corresponds to FPDFText_SetCharcodes.

Source

pub fn set_charcodes(&mut self, codes: &[u32])

👎Deprecated:

use text_set_charcodes() — matches upstream FPDFText_SetCharcodes

Non-upstream alias — use text_set_charcodes().

Corresponds to FPDFText_SetCharcodes.

Source

pub fn rendered_bitmap( &self, _page_index: usize, _scale: f32, ) -> Result<Bitmap, EditError>

Returns the rendered bitmap for this text object at the given scale.

§Not Supported

Rendering a page object to bitmap requires a live CPDF_Document/CPDF_Page handle not available in rpdfium’s edit layer (read-only, ADR-002).

Corresponds to FPDFTextObj_GetRenderedBitmap.

Source

pub fn text_obj_get_rendered_bitmap( &self, page_index: usize, scale: f32, ) -> Result<Bitmap, EditError>

Upstream-aligned alias for rendered_bitmap().

Corresponds to FPDFTextObj_GetRenderedBitmap.

Source

pub fn get_rendered_bitmap( &self, page_index: usize, scale: f32, ) -> Result<Bitmap, EditError>

👎Deprecated:

use text_obj_get_rendered_bitmap() — matches upstream FPDFTextObj_GetRenderedBitmap

Non-upstream alias — use text_obj_get_rendered_bitmap().

Corresponds to FPDFTextObj_GetRenderedBitmap.

Trait Implementations§

Source§

impl Clone for TextObject

Source§

fn clone(&self) -> TextObject

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 TextObject

Source§

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

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

impl Default for TextObject

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