You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thread 'main' panicked at /home/rafal/.cargo/git/checkouts/lopdf-0013854ec52a6141/c25cef3/src/document.rs:446:83:
called `Result::unwrap()` on an `Err` value: ObjectNotFound
stack backtrace:
0: rust_begin_unwind
at /rustc/7120fdac7a6e55a5e4b606256042890b36067052/library/std/src/panicking.rs:665:5
1: core::panicking::panic_fmt
at /rustc/7120fdac7a6e55a5e4b606256042890b36067052/library/core/src/panicking.rs:74:14
2: core::result::unwrap_failed
at /rustc/7120fdac7a6e55a5e4b606256042890b36067052/library/core/src/result.rs:1679:5
3: core::result::Result<T,E>::unwrap
at /rustc/7120fdac7a6e55a5e4b606256042890b36067052/library/core/src/result.rs:1102:23
4: lopdf::document::Document::get_page_resources
at /home/rafal/.cargo/git/checkouts/lopdf-0013854ec52a6141/c25cef3/src/document.rs:446:13
5: lopdf::document::Document::get_page_fonts
at /home/rafal/.cargo/git/checkouts/lopdf-0013854ec52a6141/c25cef3/src/document.rs:478:45
6: lopdf::parser_aux::<impl lopdf::document::Document>::extract_text
at /home/rafal/.cargo/git/checkouts/lopdf-0013854ec52a6141/c25cef3/src/parser_aux.rs:71:25
7: lopdf::check_file
at /home/rafal/Projekty/Rust/run_command_for_every_file/src/crates/lopdf/src/main.rs:41:29
8: lopdf::main
at /home/rafal/Projekty/Rust/run_command_for_every_file/src/crates/lopdf/src/main.rs:23:9
9: core::ops::function::FnOnce::call_once
at /rustc/7120fdac7a6e55a5e4b606256042890b36067052/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Aborted (core dumped)
code
fn check_file(file_path: &str) {
let Ok(content) = fs::read(file_path) else {
return;
};
let cursor = Cursor::new(content);
match Document::load_from(cursor) {
Ok(mut document) => {
let pages = document.get_pages();
let mut doc_clone = document.clone();
doc_clone.decompress();
for (i, _) in pages.iter().enumerate() {
let page_number = (i + 1) as u32;
let _text = document.extract_text(&[page_number]);
}
let _ = document.save_to(&mut Cursor::new(Vec::new()));
}
Err(err) => {
eprintln!("Error reading PDF contents: {}", err)
}
}
}
code
file - crash.pdf.zip
The text was updated successfully, but these errors were encountered: