NativeElixirPdfUtilities.Merge (native_elixir_pdf_utilities v0.6.0)
View SourcePDF utilities for merging documents through the shared native reader.
Notes and constraints:
- Emits a classic PDF 1.7 header and builds a fresh
xref+trailer. - Resolves classic xref tables, xref streams, and object streams before copying active objects with fresh identifiers.
- Adjusts indirect references (
n g R) to the new numbering. - Collects Page objects and builds a new
Catalog+Pagestree that references them. - Leaves stream bytes untouched and preserves declared
/Length(direct or indirect ref), only renumbering indirect references as needed.
The merger is conservative and pragmatic, targeting structural correctness for common PDFs.
Summary
Types
Mapping from original object id to new object id.
Object record captured while indexing inputs.
Byte-offset table for xref: object id -> {byte_offset, generation}.
A single token as produced by NativeElixirPdfUtilities.Tokenizer.
A list of PDF tokens.
Functions
Merge a list of PDF binaries into a single PDF binary.
Types
@type error_reason() :: :empty_pdf_list | :invalid_pdf_input
Mapping from original object id to new object id.
Object record captured while indexing inputs.
@type offsets_map() :: %{ optional(integer()) => {non_neg_integer(), non_neg_integer()} }
Byte-offset table for xref: object id -> {byte_offset, generation}.
@type pdf_bin() :: binary()
@type token() :: NativeElixirPdfUtilities.Tokenizer.token()
A single token as produced by NativeElixirPdfUtilities.Tokenizer.
@type tokens() :: [token()]
A list of PDF tokens.
Functions
@spec merge([pdf_bin()]) :: {:ok, pdf_bin()} | {:error, {error_reason(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Merge a list of PDF binaries into a single PDF binary.
It resolves active objects through the shared reader, renumbers them, collects Page objects, and emits a new Catalog/Pages tree referencing all input pages.