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: NameFont name (must match a resource font name).
font_size: f32Font size in points.
matrix: MatrixTransformation matrix (includes position).
text: StringThe text string to render.
fill_color: Option<Color>Fill color.
stroke_color: Option<Color>Stroke color.
rendering_mode: TextRenderingModeText rendering mode.
char_spacing: f32Character spacing.
word_spacing: f32Word spacing.
blend_mode: Option<BlendMode>Blend mode for compositing.
Corresponds to FPDFPageObj_GetBlendMode / FPDFPageObj_SetBlendMode.
active: boolWhether 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 BDC…EMC 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
impl TextObject
Sourcepub fn with_standard_font(font_name: &str, size: f32) -> Self
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.
Sourcepub fn with_font(registration: &FontRegistration, size: f32) -> Self
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.
Sourcepub fn from_font_registration(
font_registration: &FontRegistration,
font_size: f32,
) -> Self
👎Deprecated: use with_font() — from_font_registration is not an upstream FPDF name
pub fn from_font_registration( font_registration: &FontRegistration, font_size: f32, ) -> Self
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.
Sourcepub fn text(&self) -> &str
pub fn text(&self) -> &str
Return the text string stored in this object.
Corresponds to FPDFTextObj_GetText (without requiring a text_page).
Sourcepub fn text_obj_get_text(&self) -> &str
pub fn text_obj_get_text(&self) -> &str
Upstream-aligned alias for text().
Corresponds to FPDFTextObj_GetText.
pub fn get_text(&self) -> &str
use text_obj_get_text() — matches upstream FPDFTextObj_GetText
Sourcepub fn font_size(&self) -> f32
pub fn font_size(&self) -> f32
Return the font size in points.
Corresponds to FPDFTextObj_GetFontSize.
Sourcepub fn text_obj_get_font_size(&self) -> f32
pub fn text_obj_get_font_size(&self) -> f32
Upstream-aligned alias for font_size().
Corresponds to FPDFTextObj_GetFontSize.
pub fn get_font_size(&self) -> f32
use text_obj_get_font_size() — matches upstream FPDFTextObj_GetFontSize
Sourcepub fn rendering_mode(&self) -> TextRenderingMode
pub fn rendering_mode(&self) -> TextRenderingMode
Return the text rendering mode.
Corresponds to FPDFTextObj_GetTextRenderMode.
Sourcepub fn text_obj_get_text_render_mode(&self) -> TextRenderingMode
pub fn text_obj_get_text_render_mode(&self) -> TextRenderingMode
Upstream-aligned alias for rendering_mode().
Corresponds to FPDFTextObj_GetTextRenderMode.
pub fn get_text_render_mode(&self) -> TextRenderingMode
use text_obj_get_text_render_mode() — matches upstream FPDFTextObj_GetTextRenderMode
Sourcepub fn font_name(&self) -> &Name
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).
Sourcepub fn text_obj_get_font(&self) -> &Name
pub fn text_obj_get_font(&self) -> &Name
Upstream-aligned alias for font_name().
Corresponds to FPDFTextObj_GetFont.
pub fn get_font(&self) -> &Name
use text_obj_get_font() — matches upstream FPDFTextObj_GetFont
Sourcepub fn set_fill_color(&mut self, color: Color)
pub fn set_fill_color(&mut self, color: Color)
Sets the fill color.
Corresponds to FPDFPageObj_SetFillColor.
Sourcepub fn fill_color(&self) -> Option<&Color>
pub fn fill_color(&self) -> Option<&Color>
Returns the fill color, if set (upstream FPDFPageObj_GetFillColor).
Sourcepub fn page_obj_get_fill_color(&self) -> Option<&Color>
pub fn page_obj_get_fill_color(&self) -> Option<&Color>
Upstream-aligned alias for fill_color().
Corresponds to FPDFPageObj_GetFillColor.
Sourcepub fn get_fill_color(&self) -> Option<&Color>
👎Deprecated: use page_obj_get_fill_color() — matches upstream FPDFPageObj_GetFillColor
pub fn get_fill_color(&self) -> Option<&Color>
use page_obj_get_fill_color() — matches upstream FPDFPageObj_GetFillColor
Non-upstream alias — use page_obj_get_fill_color().
Corresponds to FPDFPageObj_GetFillColor.
Sourcepub fn set_stroke_color(&mut self, color: Color)
pub fn set_stroke_color(&mut self, color: Color)
Sets the stroke color.
Corresponds to FPDFPageObj_SetStrokeColor.
Sourcepub fn stroke_color(&self) -> Option<&Color>
pub fn stroke_color(&self) -> Option<&Color>
Returns the stroke color, if set (upstream FPDFPageObj_GetStrokeColor).
Sourcepub fn page_obj_get_stroke_color(&self) -> Option<&Color>
pub fn page_obj_get_stroke_color(&self) -> Option<&Color>
Upstream-aligned alias for stroke_color().
Corresponds to FPDFPageObj_GetStrokeColor.
Sourcepub fn get_stroke_color(&self) -> Option<&Color>
👎Deprecated: use page_obj_get_stroke_color() — matches upstream FPDFPageObj_GetStrokeColor
pub fn get_stroke_color(&self) -> Option<&Color>
use page_obj_get_stroke_color() — matches upstream FPDFPageObj_GetStrokeColor
Non-upstream alias — use page_obj_get_stroke_color().
Corresponds to FPDFPageObj_GetStrokeColor.
Sourcepub fn set_font_size(&mut self, size: f32)
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).
Sourcepub fn set_text(&mut self, text: impl Into<String>)
pub fn set_text(&mut self, text: impl Into<String>)
Sets the text content of this text object.
Corresponds to FPDFTextObj_SetText.
Sourcepub fn text_obj_set_text(&mut self, text: impl Into<String>)
pub fn text_obj_set_text(&mut self, text: impl Into<String>)
Upstream-aligned alias for set_text().
Corresponds to FPDFTextObj_SetText.
Sourcepub fn set_text_content(&mut self, text: String)
👎Deprecated: use set_text() — matches upstream FPDFText_SetText
pub fn set_text_content(&mut self, text: String)
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.
Sourcepub fn set_rendering_mode(&mut self, mode: TextRenderingMode)
pub fn set_rendering_mode(&mut self, mode: TextRenderingMode)
Sets the text rendering mode.
Corresponds to FPDFTextObj_SetTextRenderMode.
Sourcepub fn text_obj_set_text_render_mode(&mut self, mode: TextRenderingMode)
pub fn text_obj_set_text_render_mode(&mut self, mode: TextRenderingMode)
Upstream-aligned alias for Self::set_rendering_mode().
Corresponds to FPDFTextObj_SetTextRenderMode.
Sourcepub fn set_text_render_mode(&mut self, mode: TextRenderingMode)
👎Deprecated: use text_obj_set_text_render_mode() — matches upstream FPDFTextObj_SetTextRenderMode
pub fn set_text_render_mode(&mut self, mode: TextRenderingMode)
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.
Sourcepub fn transform(&mut self, m: &Matrix)
pub fn transform(&mut self, m: &Matrix)
Applies a matrix transform by pre-multiplying into the object’s matrix.
Corresponds to FPDFPageObj_Transform.
Sourcepub fn blend_mode(&self) -> Option<BlendMode>
pub fn blend_mode(&self) -> Option<BlendMode>
Returns the blend mode for this object.
Corresponds to FPDFPageObj_GetBlendMode.
Sourcepub fn page_obj_get_blend_mode(&self) -> Option<BlendMode>
pub fn page_obj_get_blend_mode(&self) -> Option<BlendMode>
Upstream-aligned alias for blend_mode().
Corresponds to FPDFPageObj_GetBlendMode.
Sourcepub fn get_blend_mode(&self) -> Option<BlendMode>
👎Deprecated: use page_obj_get_blend_mode() — matches upstream FPDFPageObj_GetBlendMode
pub fn get_blend_mode(&self) -> Option<BlendMode>
use page_obj_get_blend_mode() — matches upstream FPDFPageObj_GetBlendMode
Non-upstream alias — use page_obj_get_blend_mode().
Corresponds to FPDFPageObj_GetBlendMode.
Sourcepub fn set_blend_mode(&mut self, mode: Option<BlendMode>)
pub fn set_blend_mode(&mut self, mode: Option<BlendMode>)
Sets the blend mode for this object.
Corresponds to FPDFPageObj_SetBlendMode.
Sourcepub fn mark_count(&self) -> usize
pub fn mark_count(&self) -> usize
Return the number of content marks on this object.
Corresponds to FPDFPageObj_CountMarks.
Sourcepub fn page_obj_count_marks(&self) -> usize
pub fn page_obj_count_marks(&self) -> usize
Upstream-aligned alias for mark_count().
Corresponds to FPDFPageObj_CountMarks.
Sourcepub fn count_marks(&self) -> usize
👎Deprecated: use page_obj_count_marks() — matches upstream FPDFPageObj_CountMarks
pub fn count_marks(&self) -> usize
use page_obj_count_marks() — matches upstream FPDFPageObj_CountMarks
Non-upstream alias — use page_obj_count_marks().
Corresponds to FPDFPageObj_CountMarks.
Sourcepub fn mark(&self, index: usize) -> Option<&ContentMark>
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.
Sourcepub fn page_obj_get_mark(&self, index: usize) -> Option<&ContentMark>
pub fn page_obj_get_mark(&self, index: usize) -> Option<&ContentMark>
Upstream-aligned alias for mark().
Corresponds to FPDFPageObj_GetMark.
Sourcepub fn get_mark(&self, index: usize) -> Option<&ContentMark>
👎Deprecated: use page_obj_get_mark() — matches upstream FPDFPageObj_GetMark
pub fn get_mark(&self, index: usize) -> Option<&ContentMark>
use page_obj_get_mark() — matches upstream FPDFPageObj_GetMark
Non-upstream alias — use page_obj_get_mark().
Corresponds to FPDFPageObj_GetMark.
Sourcepub fn add_mark(&mut self, name: impl Into<String>) -> &mut ContentMark
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.
Sourcepub fn remove_mark(&mut self, index: usize) -> bool
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.
Sourcepub fn marks(&self) -> &[ContentMark]
pub fn marks(&self) -> &[ContentMark]
Return a slice of all content marks on this object.
Sourcepub fn marked_content_id(&self) -> Option<i64>
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.
Sourcepub fn page_obj_get_marked_content_id(&self) -> Option<i64>
pub fn page_obj_get_marked_content_id(&self) -> Option<i64>
Upstream-aligned alias for marked_content_id().
Corresponds to FPDFPageObj_GetMarkedContentID.
Sourcepub fn get_marked_content_id(&self) -> Option<i64>
👎Deprecated: use page_obj_get_marked_content_id() — matches upstream FPDFPageObj_GetMarkedContentID
pub fn get_marked_content_id(&self) -> Option<i64>
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.
Sourcepub fn has_transparency(&self) -> bool
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.
Sourcepub fn is_transparent(&self) -> bool
👎Deprecated: use has_transparency() — matches upstream FPDFPageObj_HasTransparency
pub fn is_transparent(&self) -> bool
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.
Sourcepub fn object_type(&self) -> u32
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.
Sourcepub fn get_object_type(&self) -> u32
👎Deprecated: use page_obj_get_type() — matches upstream FPDFPageObj_GetType
pub fn get_object_type(&self) -> u32
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.
Sourcepub fn page_obj_get_type(&self) -> u32
pub fn page_obj_get_type(&self) -> u32
Upstream-aligned alias for object_type().
Corresponds to FPDFPageObj_GetType.
pub fn get_type(&self) -> u32
use page_obj_get_type() — matches upstream FPDFPageObj_GetType
Sourcepub fn rotated_bounds(&self) -> Option<[Point; 4]>
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.
Sourcepub fn page_obj_get_rotated_bounds(&self) -> Option<[Point; 4]>
pub fn page_obj_get_rotated_bounds(&self) -> Option<[Point; 4]>
Upstream-aligned alias for rotated_bounds().
Corresponds to FPDFPageObj_GetRotatedBounds.
Sourcepub fn get_rotated_bounds(&self) -> Option<[Point; 4]>
👎Deprecated: use page_obj_get_rotated_bounds() — matches upstream FPDFPageObj_GetRotatedBounds
pub fn get_rotated_bounds(&self) -> Option<[Point; 4]>
use page_obj_get_rotated_bounds() — matches upstream FPDFPageObj_GetRotatedBounds
Non-upstream alias — use page_obj_get_rotated_bounds().
Corresponds to FPDFPageObj_GetRotatedBounds.
Sourcepub fn set_char_codes(&mut self, codes: &[u32])
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.
Sourcepub fn text_set_charcodes(&mut self, codes: &[u32])
pub fn text_set_charcodes(&mut self, codes: &[u32])
Upstream-aligned alias for set_char_codes().
Corresponds to FPDFText_SetCharcodes.
Sourcepub fn set_charcodes(&mut self, codes: &[u32])
👎Deprecated: use text_set_charcodes() — matches upstream FPDFText_SetCharcodes
pub fn set_charcodes(&mut self, codes: &[u32])
use text_set_charcodes() — matches upstream FPDFText_SetCharcodes
Non-upstream alias — use text_set_charcodes().
Corresponds to FPDFText_SetCharcodes.
Sourcepub fn rendered_bitmap(
&self,
_page_index: usize,
_scale: f32,
) -> Result<Bitmap, EditError>
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.
Sourcepub fn text_obj_get_rendered_bitmap(
&self,
page_index: usize,
scale: f32,
) -> Result<Bitmap, EditError>
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.
Sourcepub fn get_rendered_bitmap(
&self,
page_index: usize,
scale: f32,
) -> Result<Bitmap, EditError>
👎Deprecated: use text_obj_get_rendered_bitmap() — matches upstream FPDFTextObj_GetRenderedBitmap
pub fn get_rendered_bitmap( &self, page_index: usize, scale: f32, ) -> Result<Bitmap, EditError>
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
impl Clone for TextObject
Source§fn clone(&self) -> TextObject
fn clone(&self) -> TextObject
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more