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
impl LayoutMode
Sourcepub fn as_str(self) -> &'static str
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}Trait Implementations§
Source§impl Clone for LayoutMode
impl Clone for LayoutMode
impl Copy for LayoutMode
Source§impl Debug for LayoutMode
impl Debug for LayoutMode
Source§impl Default for LayoutMode
impl Default for LayoutMode
impl Eq for LayoutMode
Source§impl PartialEq for LayoutMode
impl PartialEq for LayoutMode
impl StructuralPartialEq for LayoutMode
Auto Trait Implementations§
impl Freeze for LayoutMode
impl RefUnwindSafe for LayoutMode
impl Send for LayoutMode
impl Sync for LayoutMode
impl Unpin for LayoutMode
impl UnsafeUnpin for LayoutMode
impl UnwindSafe for LayoutMode
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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> ⓘ
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 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> ⓘ
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