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: StringThe text string
bbox: RectBounding box of the text
font: FontSpecFont specification
style: TextStyleText 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
impl TextContent
Sourcepub fn new(
text: impl Into<String>,
bbox: Rect,
font: FontSpec,
style: TextStyle,
) -> Self
pub fn new( text: impl Into<String>, bbox: Rect, font: FontSpec, style: TextStyle, ) -> Self
Create a new text content element.
Sourcepub fn with_reading_order(self, order: usize) -> Self
pub fn with_reading_order(self, order: usize) -> Self
Create text content with reading order.
Sourcepub fn with_artifact_type(self, artifact_type: ArtifactType) -> Self
pub fn with_artifact_type(self, artifact_type: ArtifactType) -> Self
Set the artifact type.
Sourcepub fn with_matrix(self, matrix: [f32; 6]) -> Self
pub fn with_matrix(self, matrix: [f32; 6]) -> Self
Set the transformation matrix.
Sourcepub fn with_origin(self, origin: Point) -> Self
pub fn with_origin(self, origin: Point) -> Self
Set the origin point.
Sourcepub fn with_rotation(self, degrees: f32) -> Self
pub fn with_rotation(self, degrees: f32) -> Self
Set the rotation angle in degrees.
Sourcepub fn is_rotated(&self) -> bool
pub fn is_rotated(&self) -> bool
Check if this text is rotated (non-zero rotation).
Sourcepub fn rotation_radians(&self) -> Option<f32>
pub fn rotation_radians(&self) -> Option<f32>
Get rotation angle in radians.
Sourcepub fn get_matrix(&self) -> Option<[f32; 6]>
pub fn get_matrix(&self) -> Option<[f32; 6]>
Get the transformation matrix if available.
Trait Implementations§
Source§impl Clone for TextContent
impl Clone for TextContent
Source§impl Debug for TextContent
impl Debug for TextContent
Source§impl Default for TextContent
impl Default for TextContent
Source§impl From<TextContent> for TextSpan
Convert from TextContent to TextSpan (for backward compatibility).
impl From<TextContent> for TextSpan
Convert from TextContent to TextSpan (for backward compatibility).