Skip to main content

TextCodeEntry

Struct TextCodeEntry 

Source
pub struct TextCodeEntry {
    pub content: String,
    pub x: Option<f64>,
    pub y: Option<f64>,
    pub delta_x: Vec<f64>,
    pub delta_y: Vec<f64>,
    pub page: usize,
    pub boundary: ST_Box,
    pub font_size: f64,
    pub ctm: Option<[f64; 6]>,
}
Expand description

带上下文的 TextCode 条目,用于跨 TextCode 边界的关键字搜索。

对应 Java: TextCode + KeywordResourceboundaryMapping 条目)

将 OFD 文字定位信息(TextCode)与所属文本对象属性(边界框、字号)绑定。 contentxydelta_xdelta_y 来自 OFD TextCode 元素; pageboundaryfont_size 来自父 TextObject 及其所属页面。

Fields§

§content: String

文字内容。

§x: Option<f64>

文本起始 X 坐标(mm,相对于父 TextObject 边界)。None 表示继承前一个 TextCode 位置。

§y: Option<f64>

文本起始 Y 坐标(mm)。None 表示继承前一个 TextCode 位置。

§delta_x: Vec<f64>

X 方向逐字符偏移(单位 mm,已展开压缩格式)。

§delta_y: Vec<f64>

Y 方向逐字符偏移(单位 mm,已展开压缩格式)。

§page: usize

所在页码(从 1 开始)。

§boundary: ST_Box

父文本对象边界框(mm)。

§font_size: f64

字号(mm,对应 OFD CT_Text 的 Size 属性)。

§ctm: Option<[f64; 6]>

仿射变换矩阵(可选),对应 OFD CT_Text 的 CTM 属性。

6 元素 [a, b, c, d, e, f],变换公式:

  • x' = a * x + c * y + e
  • y' = b * x + d * y + f

对应 Java: CT_Text.getCTM() + KeywordExtractor#getCtmKeywordPosition

Implementations§

Source§

impl TextCodeEntry

Source

pub fn new( content: impl Into<String>, page: usize, boundary: ST_Box, font_size: f64, ) -> Self

创建新的 TextCode 条目。

Source

pub fn coordinate(self, x: f64, y: f64) -> Self

设置坐标。

Source

pub fn delta_x(self, deltas: Vec<f64>) -> Self

设置 X 方向偏移。

Source

pub fn delta_y(self, deltas: Vec<f64>) -> Self

设置 Y 方向偏移。

Source

pub fn ctm(self, ctm: [f64; 6]) -> Self

设置仿射变换矩阵(CTM)。

对应 Java: CT_Text.getCTM()KeywordExtractor#getCtmKeywordPosition 中的使用。

6 元素 [a, b, c, d, e, f],变换公式:

  • x' = a * x + c * y + e
  • y' = b * x + d * y + f

Trait Implementations§

Source§

impl Clone for TextCodeEntry

Source§

fn clone(&self) -> TextCodeEntry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TextCodeEntry

Source§

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

Formats the value using the given formatter. 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, 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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.