NativeElixirPdfUtilities.HtmlToPdf.Layout (native_elixir_pdf_utilities v1.1.0)
View SourceLayout engine for the native HTML-to-PDF renderer.
Lays out block text elements, inline text runs, box styling, lists, link annotation bounds, deterministic tables, a documented flexbox/grid subset, image boxes, embedded-font text metrics, and pagination metadata.
Replaced inline images retain styled-node display: :image with
image_display: :inline and become explicit :inline_image runs. Atomic
measurements use _inline_content_width, _inline_content_height, and
_inline_baseline_depth measured down from the border-box top. The bottom
margin edge supplies an image's baseline. Painted boxes keep PDF bottom-left
coordinates; optional link_rect is the clickable border box, independent of
fitted image ink. Relative positioning and pagination move both rectangles.
Summary
Functions
Converts a styled document tree into a layout tree.
Lays out an existing styled surface at explicit nonnegative point dimensions, including a zero client area.
Measures an already styled child in its existing issued document context.
Paints a validator-prepared CSS background in an already allocated content rectangle.
Paints canonically validated closed editor text using the ordinary inline line, glyph and clipping geometry.
Resolves a validator-prepared CSS box content dimension with the shared min/max and box-sizing rules.
Resolves issued lazy image candidates and SVG viewports from the surviving final layout boxes.
Types
@type box() :: map()
@type layout_tree() :: %{ type: :layout, page_size: term(), margin: term(), margins: NativeElixirPdfUtilities.HtmlToPdf.PageGeometry.margins(), boxes: [box()] }
@type render_option() :: NativeElixirPdfUtilities.HtmlToPdf.render_option()
Functions
@spec layout(term(), term()) :: {:ok, layout_tree()} | {:error, :invalid_layout | :invalid_margin | :invalid_page_size} | {:error, {:invalid_layout | :unsupported_html | :resource_limit_exceeded, NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Converts a styled document tree into a layout tree.
@spec layout_viewport(term(), term(), term()) :: {:ok, layout_tree()} | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Lays out an existing styled surface at explicit nonnegative point dimensions, including a zero client area.
@spec measure_child(term(), term(), term()) :: {:ok, map()} | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Measures an already styled child in its existing issued document context.
Returns intrinsic widths, layout/ink extents and ordered native paint boxes in
points relative to the alphabetic baseline, positive y upwards. Forced breaks,
links, images, decorations and form metadata retain their native representation.
No parsing, font registration, resource-context creation, pagination or implicit
viewport clipping occurs. Atomic elements retain their existing baseline rules.
Prepared MathML retains its preferred widths independently of actual advance
and paint geometry.
Ordinary block boxes use their allocated containing width, while their
preferred widths use the shared CSS intrinsic and min/max sizing rules with
an indefinite percentage basis. Authored box sizing applies to both axes.
first_alphabetic_baseline records the first content baseline relative to the
atomic alphabetic baseline, for MathML Core block-box composition.
typographic_width records the unpositioned final line endpoint: occupied
predecessor fragments followed by the final fragment's actual advance.
Relative offsets and transforms affect paint, independently of this extent.
The optional :formatting_context is :flow by default. :math, :flex
and :grid use CSS's block-container box for authored inline flow items;
the source node and its computed display remain unchanged.
Paints a validator-prepared CSS background in an already allocated content rectangle.
Paints canonically validated closed editor text using the ordinary inline line, glyph and clipping geometry.
@spec resolve_content_size(map(), :width | :height, number() | nil, number() | nil) :: number() | nil
Resolves a validator-prepared CSS box content dimension with the shared min/max and box-sizing rules.
@spec resolve_images(layout_tree()) :: {:ok, layout_tree()} | {:error, {atom(), map()}}
Resolves issued lazy image candidates and SVG viewports from the surviving final layout boxes.