Skip to main content

LayoutMode

Enum LayoutMode 

Source
pub enum LayoutMode {
    Auto,
    Rebuild,
    Raw,
}
Expand description

版式模式(对齐 Python layout_mode:auto / rebuild / raw)。

Variants§

§

Auto

自动(默认):行归并 + 表格识别 + 多栏排序。

Rust 逐文本对象取 bbox,没有 Python 的「整页文本直取」路径,因此 Auto 与 Rebuild 行为一致(保留三档是为了 CLI/配置与 Python 对齐)。

§

Rebuild

强制重排版式(同 Auto)。

§

Raw

不重排:按内容流顺序输出段落,不做行归并 / 表格 / 分栏。

Implementations§

Source§

impl LayoutMode

Source

pub fn as_str(self) -> &'static str

模式名(CLI、日志、meta.extra.pdf.layout_modes 用)。

Examples found in repository?
examples/layout_modes.rs (line 35)
24fn main() -> Result<(), Box<dyn std::error::Error>> {
25    let path = std::env::args()
26        .nth(1)
27        .unwrap_or_else(|| "doc.pdf".to_string());
28
29    for mode in [LayoutMode::Auto, LayoutMode::Raw] {
30        match engine_with(mode, Some(3)).parse(&path) {
31            Ok(doc) => {
32                let blocks: usize = doc.pages.iter().map(|p| p.blocks.len()).sum();
33                println!(
34                    "{:>7}: {} 页 / {} 块 / {} 字符",
35                    mode.as_str(),
36                    doc.pages.len(),
37                    blocks,
38                    doc.meta.text_length
39                );
40                if let Some(page) = doc.pages.first() {
41                    for block in page.blocks.iter().take(3) {
42                        println!("         {:?}: {}", block.kind, block.content);
43                    }
44                }
45            }
46            Err(e) => println!("{:>7}: 失败 [{}] {}", mode.as_str(), e.code, e.message),
47        }
48    }
49    Ok(())
50}
Source

pub fn parse(s: &str) -> Option<Self>

解析模式名(大小写不敏感);非法值返回 None。

Source

pub fn reflows(self) -> bool

是否做版式重排(raw 为 false)。

Trait Implementations§

Source§

impl Clone for LayoutMode

Source§

fn clone(&self) -> Self

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 Copy for LayoutMode

Source§

impl Debug for LayoutMode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for LayoutMode

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for LayoutMode

Source§

impl PartialEq for LayoutMode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LayoutMode

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.