Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsafe get and Missing char #60

Open
0xMimir opened this issue Jun 20, 2023 · 3 comments
Open

Unsafe get and Missing char #60

0xMimir opened this issue Jun 20, 2023 · 3 comments

Comments

@0xMimir
Copy link

0xMimir commented Jun 20, 2023

When running examples/extract.rs on lockchain_for_deep_learning.pdf I get following error:

thread 'main' panicked at 'no entry found for key', src/lib.rs:466:58
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Error happens in following line (src/lib.rs) line 4666:

dlog!("{} {}", code, unicode_map[&(code as u32)]);

When replaced with

dlog!("{} {}", code, unicode_map.get(&(code as u32)));

Error message changes to

thread 'main' panicked at 'missing char 2 in map {130: " ", 128: "•"} for <</BaseFont /QAJSTB+AdvPSSym/Encoding 1219 0 R/FirstChar 2/FontDescriptor 1221 0 R/LastChar 130/Subtype /Type1/ToUnicode 1202 0 R/Type /Font/Widths [791 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 458 0 0]>>', src/lib.rs:873:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@0xMimir
Copy link
Author

0xMimir commented Jun 20, 2023

Here is pdf causing the issue: blockchain_for_deep_learning.pdf

@piotroxp
Copy link

I am running into the same issue for many of my PDFs from scientific publishers.

Regardless of font, for me its an issue with UTF8 encoding. At least from a first shot at a solution, it seems all PDFs need to be converted to utf8 on load.

I am hallucinating here, but i am also learning Rust at the same time as building a tool for myself.

@anagrius
Copy link

anagrius commented Aug 3, 2023

Same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants