The immutable in-memory representation of an opened PDF.
Holds the original source bytes, the parsed xref_map and trailer, the
pending dirty_objects overlay (edits, applied at serialize time), and the
captured revision/xref style needed for byte-exact incremental updates. Lazy
projections (glyphs, uid_index) are derived on demand and reset whenever
the dirty overlay changes (see commit_dirty/2). Treated as opaque by
callers — construct it via PdfEx.open/1, never by hand.
Summary
Functions
Installs a new dirty overlay and drops the derived projections
(glyphs, uid_index) — any object change can invalidate them.
Types
@type dirty_entry() :: {:update, any()} | :free
@type generation() :: non_neg_integer()
@type object_id() :: pos_integer()
@type offset_entry() :: {:resolved, non_neg_integer()} | {:compressed, object_id(), non_neg_integer()} | :free
@type ref_key() :: {object_id(), generation()}
@type t() :: %PdfEx.Document{ dirty_objects: %{required(ref_key()) => dirty_entry()}, glyphs: %{required(ref_key()) => [PdfEx.Model.Glyph.t()]} | nil, object_cache: %{required(ref_key()) => any()}, revision_xref_offset: non_neg_integer() | nil, source: binary(), trailer: map(), uid_index: %{ required(binary()) => {:glyph, ref_key(), non_neg_integer(), non_neg_integer()} } | nil, xref_map: %{required(ref_key()) => offset_entry()}, xref_style: :classic | :stream | nil }
Functions
@spec commit_dirty(t(), %{required(ref_key()) => dirty_entry()}) :: t()
Installs a new dirty overlay and drops the derived projections
(glyphs, uid_index) — any object change can invalidate them.
Every dirty-object write must go through here; updating dirty_objects
with plain struct-update syntax leaves stale projections behind.