Skip to main content

Module graph

Module graph 

Source
Expand description

§ObjectGraph — one read view over “the document as it is right now”

Pass 3.1 could get away without this. Pass 3.2 cannot, and the reason is recorded verbatim in pdfcer_core::edit’s own module docs:

⚠️ Pass 3.2 must replace this with an overlay-aware walk. The moment an edit can add or remove a Kids entry, patching a base-derived list is not an approximation — it is wrong.

Pass 3.1’s mutations (/Info, /Rotate) changed dictionary values only, so crate::page_tree::pages could walk the base document and then patch each leaf’s rotation from the overlay. A structural operation changes the page tree’s shape: after a delete, the base walk still returns the deleted page; after a reorder, it returns the old order. Patching cannot fix either.

§The shape of the fix, and why it is a trait

Every consumer of the object graph — the page-tree walk, the outline walk, the cross-document copier, the dangling-reference census — needs exactly three primitives:

  1. fetch an indirect object by identity;
  2. follow a reference chain to a non-reference value (§7.3.10);
  3. read a trailer entry (in practice only /Root).

Document provides all three, and so does an EditSession with its overlay applied. Making that a trait rather than duplicating each walk means there is exactly one page-tree walk in pdfcer, and it is automatically correct for both views. A second copy specialised to sessions is precisely the kind of drift that eventually renders a deleted page.

§Why the resolution rules live here as provided methods

§7.3.10’s rules — dangling reference yields null and “shall not be considered an error”, a generation mismatch is a dangling reference, a reference chain is depth-guarded — are spec behaviour, not view behaviour. Implementing them once as provided methods on the trait makes it impossible for a new view to get them subtly different; an implementor supplies only ObjectGraph::value and ObjectGraph::trailer_entry, which are the parts that genuinely differ.

§Spec sources

  • iso32000__s__7.3.10.md — indirect objects, dangling references, substitutability
  • iso32000__s__7.7.2.md — the document catalog, reached via the trailer’s /Root

Traits§

ObjectGraph
A read-only view of one PDF document’s object graph.