NativeElixirPdfUtilities.Validators.MergeValidator (native_elixir_pdf_utilities v0.13.0)
View SourceMerge-specific validation and rewrite preparation.
The validator consumes a shared PDF validation context, materializes the effective page values needed by a flattened output page tree, proves that retained objects can be serialized, and constructs complete generation-aware reference-remapping tables before the writer runs.
Summary
Types
Prepared inherited page tokens keyed by original page object number.
A validated input ready for reference allocation and PDF writing.
A parsed object retained for merge serialization.
Functions
Prepares one shared validated PDF context for merge rewriting.
Allocates non-colliding output identifiers and validates complete reference remapping.
Splits a dictionary's top-level token list around a named value.
Takes one complete serialized PDF value from the beginning of a token list.
Validates the public merge input boundary.
Types
@type inherited_pages() :: %{ optional(non_neg_integer()) => %{ resources: [NativeElixirPdfUtilities.Tokenizer.token()] | nil, mediabox: [NativeElixirPdfUtilities.Tokenizer.token()], cropbox: [NativeElixirPdfUtilities.Tokenizer.token()] | nil, rotate: [NativeElixirPdfUtilities.Tokenizer.token()] | nil } }
Prepared inherited page tokens keyed by original page object number.
@type input_context() :: %{ :objects => [object_context()], :pages => [NativeElixirPdfUtilities.Validators.PdfValidator.ref()], :inherited => inherited_pages(), optional(:map) => %{ optional(NativeElixirPdfUtilities.Validators.PdfValidator.ref()) => non_neg_integer() } }
A validated input ready for reference allocation and PDF writing.
@type object_context() :: %{ obj: non_neg_integer(), gen: non_neg_integer(), tokens: [NativeElixirPdfUtilities.Tokenizer.token()], value: NativeElixirPdfUtilities.Validators.PdfValidator.value() }
A parsed object retained for merge serialization.
Functions
@spec prepare(NativeElixirPdfUtilities.Validators.PdfValidator.context()) :: {:ok, input_context()} | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Prepares one shared validated PDF context for merge rewriting.
@spec prepare_remapping([input_context()], pos_integer()) :: {:ok, [input_context()]} | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Allocates non-colliding output identifiers and validates complete reference remapping.
@spec split_dictionary_value([NativeElixirPdfUtilities.Tokenizer.token()], binary()) :: {:ok, [NativeElixirPdfUtilities.Tokenizer.token()], [NativeElixirPdfUtilities.Tokenizer.token()], [NativeElixirPdfUtilities.Tokenizer.token()]} | :error
Splits a dictionary's top-level token list around a named value.
Returns the tokens before the key, the complete value tokens, and the tokens
following the value. Names nested inside dictionary or array values are not
considered. Missing keys and incomplete values return :error.
@spec take_value_tokens([NativeElixirPdfUtilities.Tokenizer.token()]) :: {:ok, [NativeElixirPdfUtilities.Tokenizer.token()], [NativeElixirPdfUtilities.Tokenizer.token()]} | :error
Takes one complete serialized PDF value from the beginning of a token list.
Merge rewriting uses this prepared-token utility when replacing top-level dictionary entries without reparsing PDF bytes.
@spec validate_inputs(term()) :: {:ok, [binary()]} | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Validates the public merge input boundary.