A Pure-Rust PDF Reader for Private Document Ingest
rusty_pdf_core opened 986 of 989 test PDFs with no panics and no timeouts. What that means if your product takes in files from customers, and what it leaves out.

Is there a pure-Rust PDF reader I can use to ingest customer documents?
Yes, with limits. rusty_pdf_core 0.2.0 reads objects, pages, text and embedded images, handles encrypted and damaged files, and forbids unsafe code in its own source. It has no renderer or writer yet, so it covers the reading half of ingest only.
If you take in PDFs from other people, you want a pure-Rust PDF reader that treats every file as hostile. Remade with Rust has one now. rusty_pdf_core 0.2.0 is on crates.io under MIT OR Apache-2.0, with no C in it and #![forbid(unsafe_code)] on its own source. On a pinned set of 989 test PDFs it opened 986, panicked on none and timed out on none. I want to explain what that is worth to a product that ingests documents, and where it stops.
The code lives in the public rusty_pdf repository. One warning first. The name rusty_pdf on crates.io belongs to somebody else's project, so the crate you want is rusty_pdf_core. Run cargo add rusty_pdf_core and read the docs on docs.rs.
A customer's PDF is untrusted input
A PDF is not a page. It is a small database with a cross-reference table, compressed object streams, filters, optional encryption, and images stored in codecs like JBIG2 and JPEG 2000. A reader has to make sense of all of that before you see one word of text.
Most of us never think about that step, because the file came from a bank or a contract tool and it just opens. Ingest is different. A support portal, a document inbox and a shared drive all take files from people you have never met. The parser is the first thing that touches them.
When that parser is written in C, a bug in it can be memory corruption on your machine. CISA's case for memory-safe roadmaps makes that argument for the whole industry, and the JBIG2 story behind FORCEDENTRY is the PDF-shaped version of it.
It matters more to us than to most, because MATA's whole pitch is that your files stay on hardware you own. If a customer drops a contract into a local tool, the parser runs right next to their data. If you are building private RAG, the same applies: RAG Converter and the notes on turning business files into AI-readable chunks start with getting text out of a file, and PDF is the file people send most.
What this pure-Rust PDF reader opens today
The numbers below come from the repo's own README, not from me. The test set is the pdf.js corpus, pinned to one commit, 989 files, each checked against a manifest hash. Passwords come from pdf.js's own test manifest.
Damaged and encrypted files
The reader handles classic and stream cross-reference tables, object streams and incremental updates. When the cross-reference data is broken it rebuilds it. The tests damage that data four ways and check the repair.
For encryption it covers RC4 from 40 to 128 bit, AES-128 and AES-256, with user and owner passwords. 986 of 989 files opened. Two of the three that did not need passwords the pdf.js manifest never supplies. The third has no document catalog anywhere in it, and lopdf rejects it too.
Text, pages and scanned images
On the 989 files, page content decoded and parsed on 1,829 of 1,843 pages. Image XObjects decoded on 1,133 of 1,141. Pages give you their operators, annotations and a text layer in content order.
The image filters go through our own crates: rusty_jpeg, rusty_jpx, rusty_jbig2 and the CCITT code in rusty_tiff. You can read how two of them work in the rusty_jbig2 notes. That also explains the limit. A scanned page is an image, so this crate gives you the picture. Turning it into words is a separate OCR job, and Carmenta is ours.
What it will not do yet
There is no renderer, no font code and no document writer in the published crate. Those are planned as later phases and are not on crates.io. The crate can save, by rewrite or by incremental update, but the repo's own plan lists qpdf --check on every save as still open, along with a CPU-hour of fuzzing.
The comparison with lopdf is also partial. Where both readers open a file, the object trees match on 957 of 982. The differences inspected so far were lopdf's, but "so far" is the repo's phrase, and I'm keeping it.
Dropping it into an ingest pipeline
Here is the shape of a loop, taken from the crate's README. It loads a file, walks the pages and pulls the text out.
use rusty_pdf_core::{Document, LoadOptions};
let doc = Document::load_with(&bytes, &LoadOptions::with_password("secret"))?;
for i in 0..doc.page_count() {
let page = doc.page(i)?;
let text = page.extract_text(64 << 20)?; // byte cap for this page
}
Where it sits before OCR and chunking
In a RAG pipeline a pure-Rust PDF reader is stage one. Load the file, collect text per page, and send the text to your chunker. If a page returns almost no text, treat it as a scan: decode its images with decode_image and route them to OCR. That split keeps the cheap path cheap, since most office PDFs carry real text.
Limits you set per file
Every decode takes a byte cap. Images are bounded by their own declared size before anything is allocated. Nesting, reference chains, page trees and previous-version chains are walked with depth limits or visited sets. No allocation is sized from a number in the file without a check first. A tiny hostile file should not be able to ask for gigabytes.
The 20-second limit in the test numbers came from the test harness, not the crate. In your own service, run the reader in a worker with a clock of your own. That part is my advice, not the repo's.
Checking the claims yourself
You can reproduce the corpus run. Fetch the corpus with scripts/fetch-corpus.sh, then run the parity binary, and cargo test --workspace covers the hostile-input tests. Nobody outside the team has audited the crate. The README also says its speed passes were measured, and 0.2.0 reports 24 percent fewer instructions on page content, with wall time 1.41 times faster in one round and 1.23 times in the next.
The crate's own source forbids unsafe code, but the codecs and the zlib backend underneath it do not, so read "pure Rust" as "no C", not "no unsafe anywhere". The full list of what MATA pins is on the Remade with Rust hub, and there is a rusty_pdf page with the crate pin. The Learn library has the rest of the series, and the Freedom Guide is where the "keep it local" argument starts. The remadewithrust.com repo page covers the same crate from the Rust side. If a person needs to edit or redact the PDF rather than ingest it, Freehold PDF does that on the desktop with the same keep-it-local rule.
FAQ
Short answers already in this article.
Which crate do I add, rusty_pdf or rusty_pdf_core?
Add rusty_pdf_core. The repository is called rusty_pdf, but no crate we publish has that name. A crate called rusty_pdf on crates.io belongs to an unrelated project, so cargo add rusty_pdf installs someone else's code.
Can it pull text out of a scanned PDF?
Not by itself. A scan is an image inside the PDF, so the crate decodes that image and hands it over. Turning pixels into words takes an OCR engine. The crate's text layer reads the text a PDF stores as text, in content order.
How did it do on real-world test files?
On the pinned pdf.js corpus of 989 PDFs, 986 opened, with no panics and no timeouts at 20 seconds per file. Three did not open: two need passwords the test manifest lacks, and one has no document catalog, which lopdf also rejects.
Does it handle password-protected PDFs?
Yes for the standard security handler: RC4 from 40 to 128 bit, AES-128 and AES-256, with user and owner passwords. You pass the password in LoadOptions. A file with a different or custom handler is a gap you should test before relying on it.
Is this what RAG Converter runs on today?
Not yet. FFAI, the engine behind RAG Converter, is adopting rusty_pdf_core in its media crate right now, in place of lopdf. That work is under way and not finished, so treat this article as a guide to the crate, not a release note.

