Skip to main content

Module text_replace

Module text_replace 

Source
Expand description

Text replacement in PDF content streams (legacy convenience API).

Since Phase 1C these functions are thin wrappers over the crate::text_edit engine (see docs/TEXT_REPLACE_ENGINE_DESIGN.md §9). They keep the historical count-only contract: per-occurrence failures are not errors, they simply do not count. Callers that need per-edit diagnostics, single-occurrence selection, signature protection or stream preservation guarantees should use crate::text_edit directly.

Behaviour changes relative to the pre-1C implementation (deliberate, each covered by a flipped characterization test):

  • multiple /Contents streams are preserved instead of collapsed;
  • text covered by /ActualText is left untouched instead of desynced;
  • cross-run matches whose replacement needs a fallback font now succeed;
  • TJ kerning outside the edited region is preserved;
  • encrypted documents whose permissions forbid modification are refused.

Functions§

replace_text
Replace all occurrences of search with replacement in a page’s content.
replace_text_all_pages
Replace text across all pages in a document.