PDF Object Architecture & Decomposition
A standard Portable Document Format binary is not an image stream or sequential text markup. Under ISO 32000-1, a PDF file is an arbitrary acyclic directed graph of indirect dictionaries, content byte-streams, and reference tables linked by absolute physical byte positions. Decomposing pages cleanly requires navigating through three foundational layers:
1. Page Tree Navigation
The document root dictionary (/Catalog) points to a hierarchical balanced /Pages node. Page indices are resolved recursively through the /Kids array.
2. Graph Trimming & GC
Copying a page requires isolating only the target dictionary's downstream references. Abandoned streams (unused typefaces, non-visible vector paths, detached metadata) are pruned to keep final sizes low.
3. Xref Rebuilding
The Cross-Reference Table (xref) dictates exact file-pointer offsets. Extracting creates an entirely new trailer dictionary and sequential zero-padded 10-digit byte offset map.
When Page 1 is selectively targeted, Page 2 and its unreferenced streams (e.g. unique high-resolution bitmaps and subset CID fonts) are fully pruned from the serialization graph.