如何在 rust 中从 pdf 中提取字符串?

时间:2021-04-15 16:48:37

标签: rust

我是 Rust 的新手,我正在尝试使用 pdf_extract 包来处理 pdf。我想从pdf中提取字符串。我看到这个函数是这样定义的:

BS_OWNERDRAW

所以我使用 pub fn extract_text<P: AsRef<Path>>(path: P) -> Result<String, OutputError> 来管理错误:

extract

然而,这会返回一个错误:

use pdf_extract::extract_text;

fn main() {
    let text = extract_text("file.pdf").expect("Unable to read file");
    println!("{}", &text)
}

由于错误信息与我在thread 'main' panicked at 'attempted to leave type `linked_hash_map::Node<std::vec::Vec<u8>, object::Object>` uninitialized, which is invalid', /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/mem/mod.rs:671:9 中使用的不同,我不知道错误是什么意思。在我看来,命令 expect 有效,但它仍然出现错误。我在这里做错了什么?

0 个答案:

没有答案
相关问题