laminapdf-syntax 0.7.0

PDF syntax in Rust: the object model, lexer and parser, stream filters, decryption, and resource limits for untrusted input.
Documentation
1
2
3
4
5
6
7
8
9
10
11
# laminapdf-syntax

PDF syntax in Rust: the object model, the lexer and parser, stream filters, decryption, and resource limits for reading untrusted input safely. Most programs use it through [`laminapdf`](../laminapdf/README.md), which wraps the core crates in one API.

The PDF syntax layer of Lamina PDF's pure core (bytes in, bytes out): the object model (`Object`, `Dict`, `Name`, `PdfString`, `Stream`, `ObjRef`) with byte-exact serialization, the lexer, the object parser (which report, through `reached_end`, whether a result depended on bytes past the end of the input, so `laminapdf-cos` can parse windows of a larger file), the stream filters (Flate, PNG predictors), `crypt` (standard security handler decryption: password authentication for R2–R6, RC4/AES-128/AES-256, read only; ISO 32000-2 §7.6), and `Limits`, the resource limits of [ADR 0003](../../docs/decisions/0003-reader-tolerance-and-limits.md) that bound nesting, string length, decoded bytes and filter chains, and `text`: text-string decoding and encoding (`decode_text_string`: PDFDocEncoding, UTF-16BE, UTF-8; `encode_text_string`: PDFDocEncoding when every character has a code, else UTF-16BE with a byte order mark; §7.9.2.2) with the workspace's one PDFDocEncoding table (Annex D), in both directions. ISO 32000-2 §7.2–7.4. It also defines `Rotation`, a rotation by a multiple of 90° read from a `/Rotate` value (§7.7.3.3), so the page model and the renderers share one type.

Ported from the [`pdf-basics` spike](../../spikes/pdf-basics/rust/README.md) in architecture Round A; see its design notes for the reasoning behind the rules (number formatting, string escaping, the depth limit, predictor bounds). The file structure built on top of this crate is in [`laminapdf-cos`](../laminapdf-cos/README.md). Plan: [`docs/plans/architecture.md`](../../docs/plans/architecture.md).

```sh
cargo test -p laminapdf-syntax
```