pub struct TextBlock {
pub text: String,
pub page: u32,
pub bbox: [f64; 4],
pub font_name: String,
pub font_size: f64,
pub actual_text: Option<String>,
pub base_font: Option<String>,
pub is_bold: bool,
pub is_italic: bool,
pub color: Option<[u8; 4]>,
pub width_source: WidthSource,
pub char_bounds: Vec<[f64; 4]>,
}Expand description
A block of text extracted from a page.
Fields§
§text: StringThe extracted text content.
page: u32The page number (1-based).
bbox: [f64; 4]Bounding box [x0, y0, x1, y1] in PDF coordinates.
font_name: StringFont resource name (e.g. “F1”) — preserved for backward compatibility.
font_size: f64Font size in points.
actual_text: Option<String>/ActualText override from a surrounding marked-content sequence (BDC),
if any. PDF/UA-compliant authors use this to provide the canonical
reading-order text for ligatures or other glyph clusters whose visual
text does not match the intended characters.
base_font: Option<String>BaseFont of the active font dict with any 6-character subset prefix
stripped (e.g. Helvetica-Bold). None when the font dict has no
BaseFont entry or could not be resolved.
is_bold: boolInferred bold style. Set when any of:
FontDescriptor /FontWeight >= 700FontDescriptor /FlagsForceBold bit (bit 19) is set- the (subset-stripped) BaseFont name contains “bold”, “demi”, “semibold”, “heavy”, or “black”
is_italic: boolInferred italic style. Set when any of:
FontDescriptor /FlagsItalic bit (bit 7) is set- the BaseFont name contains “italic”, “oblique”, or “slant”
color: Option<[u8; 4]>Active non-stroking fill color as sRGB RGBA at the moment the show
operator emitted this block. None for color spaces we cannot map
without rendering (ICC, Lab, Pattern, Separation, DeviceN).
width_source: WidthSourceWhether glyph widths were measured from real font advance data or estimated.
char_bounds: Vec<[f64; 4]>Per-glyph bounding boxes in PDF user-space coordinates, one entry per
source glyph (not per Unicode scalar — ligatures count as one).
[x0, y0, x1, y1] where y0 < y1 (PDF coordinate system, y increasing up).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TextBlock
impl RefUnwindSafe for TextBlock
impl Send for TextBlock
impl Sync for TextBlock
impl Unpin for TextBlock
impl UnsafeUnpin for TextBlock
impl UnwindSafe for TextBlock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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