rusty_pdf_core
Pure-Rust PDF reader core: objects, cross-reference tables and streams,
object streams, incremental updates, broken-xref repair, the standard
security handler (RC4 40 to 128 bit, AES-128, AES-256), stream filters,
the page tree, content streams, a text layer, image decoding, editing and
saving. No C, #![forbid(unsafe_code)], builds for wasm32-unknown-unknown.
It is the object layer of rusty_pdf, which adds a renderer and a writer on top.
use ;
let doc = load_with?;
for i in 0..doc.page_count
let bytes = doc.save?;
Hostile input
Malformed input returns an error or a bounded result. It does not panic,
loop without progress, or allocate past Limits:
- every stream decode takes a byte cap; images are bounded by their own declared size before anything is allocated, and decompression stops at the bytes those dimensions need;
- object nesting, reference chains, page trees,
/Prevchains and object streams are walked with depth limits or visited sets; - no allocation is sized from a number in the file without a check first.
Image filters
DCTDecode, JPXDecode, JBIG2Decode and CCITTFaxDecode decode through
the house crates rusty_jpeg, rusty_jpx, rusty_jbig2 and
rusty_tiff::ccitt, each behind a default feature (dct, jpx, jbig2,
ccitt). A build that only reads objects can turn them all off.
Licence
MIT OR Apache-2.0.