NativeElixirPdfUtilities.HtmlToPdf.EmbeddedViewport (native_elixir_pdf_utilities v1.1.0)

View Source

Native child document surfaces with isolated styles and shared render budgets.

Summary

Types

Authorized child source awaiting its actual layout viewport before styling.

t()

Functions

Lays out child content in its client area, reflowing for automatic scrollbars, and returns one clipped drawing group.

Prepares authorized local or srcdoc HTML without a recursive public render or pagination.

Prepares iframe HTML with the element's initial viewport behavior.

Reads and authorizes an iframe once, dispatching HTML, literal text and PNG/JPEG initial documents, deferring Style and selected resources until layout supplies its actual client viewport. The descriptor preserves the issued context, prepared DOM, options and document URL for viewport-aware styling. Existing prepare_html/3 surfaces still expose their styled tree.

Prepares a supported local or inline image using the native image decoder and shared budget.

Prepares selected local object HTML for its isolated layout viewport.

Prepares selected local text/HTML viewports or still-image replacements without reauthorizing document mappings.

Prepares literal UTF-8 text as a bounded native document, preserving line breaks.

Styles a prepared document at client dimensions in points, with an optional separate media viewport including gutters.

Types

prepared()

@type prepared() :: %{
  optional(:initial_document_kind) => :html | :text | :raster | :svg,
  optional(:frame_border) => boolean(),
  optional(:frame_scrollbars) => :auto | :none,
  optional(:frame_margins) => map(),
  optional(:frame_name) => String.t() | nil,
  prepared_dom: NativeElixirPdfUtilities.HtmlToPdf.HtmlParser.dom_tree(),
  options: keyword(),
  document_url: String.t() | nil,
  source:
    NativeElixirPdfUtilities.Validators.ResourceValidator.document_descriptor(),
  context: NativeElixirPdfUtilities.HtmlToPdf.ResourceContext.t(),
  forms: :static | :interactive,
  host: :iframe | :object | :embed | :frame
}

Authorized child source awaiting its actual layout viewport before styling.

t()

@type t() :: %{
  optional(:prepared_dom) =>
    NativeElixirPdfUtilities.HtmlToPdf.HtmlParser.dom_tree(),
  optional(:options) => keyword(),
  optional(:document_url) => String.t() | nil,
  optional(:source) =>
    NativeElixirPdfUtilities.Validators.ResourceValidator.document_descriptor(),
  optional(:client_css_viewport) => %{width: number(), height: number()},
  optional(:media_css_viewport) => %{width: number(), height: number()},
  optional(:initial_document_kind) => :html | :text | :raster | :svg,
  optional(:frame_border) => boolean(),
  optional(:frame_scrollbars) => :auto | :none,
  optional(:frame_margins) => map(),
  optional(:frame_name) => String.t() | nil,
  tree: NativeElixirPdfUtilities.HtmlToPdf.Style.styled_tree(),
  context: NativeElixirPdfUtilities.HtmlToPdf.ResourceContext.t(),
  forms: :static | :interactive,
  host: :surface | :iframe | :object | :embed | :frame
}

Functions

layout(surface, width, height)

@spec layout(t() | prepared(), number(), number()) ::
  {:ok, map()}
  | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Lays out child content in its client area, reflowing for automatic scrollbars, and returns one clipped drawing group.

prepare_html(source, context, opts \\ [])

Prepares authorized local or srcdoc HTML without a recursive public render or pagination.

prepare_iframe(source, context, opts \\ [])

Prepares iframe HTML with the element's initial viewport behavior.

prepare_iframe_document(source, context, opts \\ [])

Reads and authorizes an iframe once, dispatching HTML, literal text and PNG/JPEG initial documents, deferring Style and selected resources until layout supplies its actual client viewport. The descriptor preserves the issued context, prepared DOM, options and document URL for viewport-aware styling. Existing prepare_html/3 surfaces still expose their styled tree.

prepare_image(reference, context, opts \\ [])

Prepares a supported local or inline image using the native image decoder and shared budget.

prepare_object_document(source, context, opts \\ [])

Prepares selected local object HTML for its isolated layout viewport.

prepare_selected(selected, context, opts, host)

Prepares selected local text/HTML viewports or still-image replacements without reauthorizing document mappings.

prepare_text(text, context, opts \\ [])

Prepares literal UTF-8 text as a bounded native document, preserving line breaks.

style_viewport(prepared, width, height, media_viewport \\ nil)

@spec style_viewport(map(), number(), number(), {number(), number()} | nil) ::
  {:ok, t()}
  | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Styles a prepared document at client dimensions in points, with an optional separate media viewport including gutters.