NativeElixirPdfUtilities.Validators.InfoValidator (native_elixir_pdf_utilities v0.18.0)

View Source

Validation and normalization for PDF information inspection and updates.

The validator consumes the shared reader context, resolves the active information dictionary, validates supported field values, prepares effective page geometry, and produces metadata patches that writers can serialize without reinterpreting caller input.

Summary

Types

Normalized common PDF information fields.

One effective page size.

Validated caller patch keyed by PDF information dictionary names.

Functions

Reads and validates the common fields in a shared PDF context.

Resolves and validates effective page sizes from a shared PDF context.

Validates and normalizes a caller-provided information patch.

Applies a prepared patch to a validated existing information dictionary.

Types

info()

@type info() :: %{
  title: String.t() | nil,
  author: String.t() | nil,
  subject: String.t() | nil,
  keywords: String.t() | nil,
  producer: String.t() | nil,
  creation_date: NaiveDateTime.t() | nil,
  modification_date: NaiveDateTime.t() | nil
}

Normalized common PDF information fields.

page_size()

@type page_size() :: %{
  page_number: pos_integer(),
  width: float(),
  height: float(),
  unit: :point,
  rotation: 0 | 90 | 180 | 270,
  media_box: %{left: float(), bottom: float(), right: float(), top: float()}
}

One effective page size.

Width and height are PDF points. MediaBox coordinates remain in the page's default user-space units before applying its UserUnit scale.

patch()

@type patch() :: %{
  optional(binary()) =>
    NativeElixirPdfUtilities.Validators.PdfValidator.value() | :remove
}

Validated caller patch keyed by PDF information dictionary names.

Functions

prepare_info(context)

Reads and validates the common fields in a shared PDF context.

prepare_page_sizes(context)

Resolves and validates effective page sizes from a shared PDF context.

prepare_patch(input)

@spec prepare_patch(term()) ::
  {:ok, patch()}
  | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Validates and normalizes a caller-provided information patch.

prepare_write(context, patch)

Applies a prepared patch to a validated existing information dictionary.