NativeElixirPdfUtilities.Validators.MergeValidator (native_elixir_pdf_utilities v0.13.0)

View Source

Merge-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

inherited_pages()

@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.

input_context()

@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.

object_context()

A parsed object retained for merge serialization.

Functions

prepare(pdf_context)

Prepares one shared validated PDF context for merge rewriting.

prepare_remapping(inputs, start_id)

@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.

split_dictionary_value(tokens, name)

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.

take_value_tokens(tokens)

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.

validate_inputs(inputs)

@spec validate_inputs(term()) ::
  {:ok, [binary()]}
  | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Validates the public merge input boundary.