pub struct TextSpan {Show 19 fields
pub text: String,
pub x: f32,
pub y: f32,
pub end_x: f32,
pub size: f32,
pub font: String,
pub font_name: String,
pub page: usize,
pub bbox: Rect,
pub bold: bool,
pub italic: bool,
pub monospace: bool,
pub serif: bool,
pub rise: f32,
pub vertical: bool,
pub invisible: bool,
pub color: Option<(f32, f32, f32)>,
pub underline: bool,
pub strikethrough: bool,
}Expand description
A positioned run of extracted text.
Fields§
§text: StringThe decoded text.
x: f32Device-space x coordinate of the span origin.
y: f32Device-space y coordinate of the span baseline.
end_x: f32Device-space x after the last glyph’s advance.
size: f32Effective font size.
font: StringFont resource name.
font_name: StringThe font’s /BaseFont name verbatim — subset prefix included —
falling back to the FontDescriptor’s /FontName; empty when the
file names the font nowhere (a missing font resource included).
page: usize0-based index of the page the span came from.
bbox: RectDevice-space box: origin to advance horizontally, the font’s
/Descent../Ascent (per-mille of the effective size) vertically.
Exact for unrotated horizontal text, an approximation under rotated
matrices; vertical writing takes the advance as its vertical extent
and half the size to each side of the baseline.
bold: boolWhether the font that produced this span is bold: FontDescriptor
/FontWeight >= 600, /Flags ForceBold, or a /StemV in bold
stem-width territory, else a Bold substring
in /BaseFont (ISO 32000-1 Table 123).
italic: boolWhether the font that produced this span is italic: FontDescriptor
/Flags Italic or a nonzero /ItalicAngle, else an Italic or
Oblique substring in /BaseFont (ISO 32000-1 Table 123).
monospace: boolFontDescriptor /Flags FixedPitch (ISO 32000-1 Table 123 bit 1).
serif: boolFontDescriptor /Flags Serif (ISO 32000-1 Table 123 bit 2).
rise: f32The text rise (Ts) the span was shown under, in unscaled text
space: positive above the baseline — a superscript/subscript
signal. The origin already includes the shift.
vertical: boolWriting mode 1: the text advances downward and bbox takes the
advance as its vertical extent.
invisible: boolShown under render mode 3 or 7 (ISO 32000-1 Table 106), which paint nothing — the shape of an OCR text layer under a scanned image.
color: Option<(f32, f32, f32)>The fill color the span was shown with, as RGB in [0, 1]. Device
gray/RGB/CMYK convert exactly; other spaces’ components are read by
count (1 gray, 3 RGB, 4 CMYK) without running the space’s
transform. None for pattern fills, which have no single color.
underline: boolA drawn ruling sits just below the baseline and covers most of the span. PDF has no underline attribute — this is read from the page’s geometry, so a table border hugging a cell’s text can read as one.
strikethrough: boolA drawn ruling crosses the span’s x-height band — geometry-read,
like underline.