mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-22 19:08:29 +00:00
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 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Brandon Thomas <[email protected]>