NativeElixirPdfUtilities.HtmlToPdf.PageGeometry (native_elixir_pdf_utilities v1.1.0)

View Source

Shared page-option cascade helpers and vertical layout-box geometry.

Page-size and margin convenience APIs delegate admission to PageGeometryValidator. This module applies canonical geometry to drawing and page-option cascades.

Summary

Functions

Returns the vertical {top, bottom} bounds for a drawing or nonpainting flow marker.

Returns a scalar for uniform margins and the four-sided map for asymmetric margins.

Returns the whole CSS-pixel source height of a validated print fragmentainer; its physical PDF clip retains the original fractional height.

Converts an applicable CSS page-margin value to a renderer margin value.

Converts an applicable CSS page-size descriptor to a renderer page-size value.

Returns pixel-snapped outer, inner and center contours for validated per-edge curved CSS borders.

Returns the content or padding edge clip after subtracting each edge from a validated rounded host.

Merges a later page-margin declaration over an earlier declaration.

Merges extracted page options while cascading partial margin longhands by side.

Resolves a nonnegative renderer margin into top, right, bottom, and left points.

Resolves a renderer page-size value to a positive {width, height} point tuple.

Returns whether a four-sided margin leaves positive printable page geometry.

Types

Functions

box_vertical_bounds(box)

@spec box_vertical_bounds(term()) :: {number(), number()}

Returns the vertical {top, bottom} bounds for a drawing or nonpainting flow marker.

Text bounds account for both the font ascent and the full line height so all rendering stages agree about the vertical space occupied by a line.

compact_margins(margins)

@spec compact_margins(margins()) :: float() | margins()

Returns a scalar for uniform margins and the four-sided map for asymmetric margins.

css_fragmentainer_source_height(height)

@spec css_fragmentainer_source_height(number()) :: float()

Returns the whole CSS-pixel source height of a validated print fragmentainer; its physical PDF clip retains the original fractional height.

css_margin_option(value)

@spec css_margin_option(String.t()) :: number() | String.t() | margins() | nil

Converts an applicable CSS page-margin value to a renderer margin value.

css_page_size_option(value)

@spec css_page_size_option(String.t()) :: page_size_input() | nil

Converts an applicable CSS page-size descriptor to a renderer page-size value.

curved_border_geometry(box, page_height)

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

Returns pixel-snapped outer, inner and center contours for validated per-edge curved CSS borders.

inset_rounded_clip(host, insets)

@spec inset_rounded_clip(map(), map()) :: map()

Returns the content or padding edge clip after subtracting each edge from a validated rounded host.

merge_margin_defaults(previous, override)

@spec merge_margin_defaults(term(), term()) :: term()

Merges a later page-margin declaration over an earlier declaration.

merge_page_options(previous, override)

@spec merge_page_options(keyword(), keyword()) :: keyword()

Merges extracted page options while cascading partial margin longhands by side.

normalize_margins(margin)

@spec normalize_margins(term()) :: {:ok, margins()} | {:error, :invalid_margin}

Resolves a nonnegative renderer margin into top, right, bottom, and left points.

normalize_page_size(page_size)

@spec normalize_page_size(term()) ::
  {:ok, {float(), float()}} | {:error, :invalid_page_size}

Resolves a renderer page-size value to a positive {width, height} point tuple.

valid_printable_area?(page_size, margins)

@spec valid_printable_area?(
  {number(), number()},
  margins()
) :: boolean()

Returns whether a four-sided margin leaves positive printable page geometry.