pdfcraft/crates/edit
EthanSuquet ff1a8b85dc
Edit text: keep the tokens a content stream shares with its neighbours (#154)
A page's /Contents array is one content stream in pieces, and a writer
may split it between any two tokens (ISO 32000-2 §7.8.2): a TJ array
can end one piece with its operator starting the next, and a
marked-content dictionary can close at the start of the next piece.

Replacing a line or rewriting a paragraph re-serialized the parsed
operators of the line's piece, and the parser keeps neither operands
left at the end of a piece nor a dictionary's closing >> at its start.
The edit dropped them: the text after the edited line vanished, and the
page was left with an operator without operands (TJ, BDC), which other
readers reject.

The piece is now rewritten by splicing: only the replaced, inserted and
removed operators change, and every other byte is copied as it was.

Co-authored-by: EthanSuquet <292885762+EthanSuquet@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
2026-10-07 21:13:04 -04:00
..
src Edit text: keep the tokens a content stream shares with its neighbours (#154) 2026-10-07 21:13:04 -04:00
Cargo.toml Rename PrintCraft to PdfCraft (#174) 2026-10-07 16:03:57 -04:00