Files
pdfcraft/crates/content
aiongg 3c64f9314e fix(content): skip a long unreadable number whole
When an operand failed to parse, the content parser went back to the
byte after its start and tried again, so a run of n bytes that never
reads as a number (a long run of '+', or digits ending in a letter) was
read again from every one of its bytes: n^2/2 bytes from a tiny
compressed stream. A failed number token longer than 64 bytes is now
skipped whole; shorter ones still recover byte by byte.
2026-10-22 17:43:03 +00:00
..

pdfcraft-content

Layer L2: content streams (ISO 32000-2 §7.8.2, §8, §9).

let parsed = parse(&stream.decoded()?);       // operators with operands and source spans
for op in &parsed.ops { if op.is("Tj") { /* … */ } }
let bytes = serialize_ops(&parsed.ops);       // write back (inline images kept whole)
let m = Matrix::from_operands(&op.operands);  // cm / Tm arithmetic, invert, bbox

The parser is tolerant (unreadable bytes are skipped and counted, never fatal) and never panics. redact and (later) edit build their interpreters on it; the graphics-state tracker and the Patch API of architecture §6 grow here.

Unfiltered inline images with built-in or Indexed colour spaces, and image masks, use their sample layout (including per-row byte padding) to locate EI. This preserves pixel bytes that look like the terminator. Filtered images and resource-defined colour spaces retain the tolerant delimiter heuristic; damaged or truncated layouts fall back to it too.