NativeElixirPdfUtilities.Validators.WriterValidator (native_elixir_pdf_utilities v1.1.0)

View Source

Semantic validation and normalization for the low-level PDF writer.

Successful preparation returns pages and normalized metadata that the byte writer can serialize without revalidating the page model.

Summary

Types

Validated input consumed by the PDF byte writer.

Functions

Identifies validated CSS text paint whose coordinate snapping or source positioning was already resolved.

Validates pages and writer options and normalizes document metadata.

Validates ordinary PDF appearance placement and clipping before native Form composition.

Prepares the genuine top-down CSS print canvas and bounded curved stroke contours from validated writer geometry.

Prepares conservative resource bounds for validated source paint, preserving negative local artwork without changing the canvas or primitives.

Reserves a link dictionary's encoded bytes before escaping and copying its URI.

Admits a generated PDF collection before allocating its entries.

Admits contiguous generated objects, including the free object-zero entry.

Checks generated object containers before they enter the PDF output.

Validates canonical per-edge colors shared by computed root geometry and PDF paint.

Validates canonical border styles shared by computed root geometry and PDF paint.

Validates an optional canonical color shared by computed styles and PDF paint.

Validates the shared writer clip rectangle grammar, including rounded outer and inner rectangles.

Validates native paint boxes using the same geometry and annotation rules as PDF writing.

Checks a widget rectangle and its clipped rectangle through the writer's existing numeric bounds before appearance allocation.

Types

context()

@type context() :: %{
  pages: [map()],
  pdf_forms: %{required(binary()) => map()},
  metadata: map(),
  outlines: [NativeElixirPdfUtilities.Validators.OutlineValidator.item()],
  compress_streams: boolean(),
  subset_fonts: boolean()
}

Validated input consumed by the PDF byte writer.

Functions

css_source_text?(box)

@spec css_source_text?(map()) :: boolean()

Identifies validated CSS text paint whose coordinate snapping or source positioning was already resolved.

prepare(pages, opts)

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

Validates pages and writer options and normalizes document metadata.

prepare_appearance_projection(appearance, matrix, polygons, bounds)

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

Validates ordinary PDF appearance placement and clipping before native Form composition.

prepare_curved_border_paint(box, page_height)

@spec prepare_curved_border_paint(map(), number()) :: map()

Prepares the genuine top-down CSS print canvas and bounded curved stroke contours from validated writer geometry.

prepare_paint_group_bounds(size, boxes)

@spec prepare_paint_group_bounds(map(), [map()]) ::
  {:ok, tuple()}
  | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Prepares conservative resource bounds for validated source paint, preserving negative local artwork without changing the canvas or primitives.

reserve_annotation_bytes(parts, uri)

@spec reserve_annotation_bytes(iodata(), binary() | nil) :: :ok

Reserves a link dictionary's encoded bytes before escaping and copying its URI.

reserve_container_entries(count)

@spec reserve_container_entries(non_neg_integer()) :: :ok

Admits a generated PDF collection before allocating its entries.

reserve_object_capacity(size)

@spec reserve_object_capacity(pos_integer()) :: :ok

Admits contiguous generated objects, including the free object-zero entry.

reserve_output_containers(body)

@spec reserve_output_containers(iodata()) :: :ok

Checks generated object containers before they enter the PDF output.

valid_border_colors?(border_colors)

@spec valid_border_colors?(term()) :: boolean()

Validates canonical per-edge colors shared by computed root geometry and PDF paint.

valid_border_styles?(border_styles)

@spec valid_border_styles?(term()) :: boolean()

Validates canonical border styles shared by computed root geometry and PDF paint.

valid_optional_color?(color)

@spec valid_optional_color?(term()) :: boolean()

Validates an optional canonical color shared by computed styles and PDF paint.

validate_clip_rectangle(clip)

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

Validates the shared writer clip rectangle grammar, including rounded outer and inner rectangles.

validate_native_boxes(boxes)

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

Validates native paint boxes using the same geometry and annotation rules as PDF writing.

validate_pdf_geometry(values)

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

Checks a widget rectangle and its clipped rectangle through the writer's existing numeric bounds before appearance allocation.