NativeElixirPdfUtilities.HtmlToPdf.PageGeometry (native_elixir_pdf_utilities v0.8.0)
View SourceNormalizes page sizes and four-sided page margins for rendering stages.
Numeric custom page-size tuples retain the renderer's compatibility rule:
values up to 20 x 20 are inches and larger values are PDF points. CSS
page-size strings always retain their declared units.
Summary
Functions
Returns a scalar for uniform margins and the four-sided map for asymmetric margins.
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.
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
@type orientation() :: :portrait | :landscape
@type page_size_input() :: page_size_name() | :"jis-b5" | :"jis-b4" | {page_size_name() | :"jis-b5" | :"jis-b4", orientation()} | {orientation(), page_size_name() | :"jis-b5" | :"jis-b4"} | {number(), number()} | String.t()
@type page_size_name() ::
:a5 | :a4 | :a3 | :b5 | :b4 | :jis_b5 | :jis_b4 | :letter | :legal | :ledger
Functions
Returns a scalar for uniform margins and the four-sided map for asymmetric margins.
Converts an applicable CSS page-margin value to a renderer margin value.
Valid CSS values that require unresolved percentages, relative units,
functions, keywords, auto, or negative geometry return nil and remain
compatibility no-ops.
@spec css_page_size_option(String.t()) :: page_size_input() | nil
Converts an applicable CSS page-size descriptor to a renderer page-size value.
Existing A4 and Letter return values are retained. Valid values that need
unresolved CSS context return nil and remain compatibility no-ops.
Merges a later page-margin declaration over an earlier declaration.
Scalar and shorthand values replace all sides. A partial side map replaces
only its declared sides, allowing @page longhands to cascade across rules
and stylesheets.
Merges extracted page options while cascading partial margin longhands by side.
Resolves a nonnegative renderer margin into top, right, bottom, and left points.
Strings use CSS shorthand order and accept one to four absolute lengths.
Margin maps may contain any of the :top, :right, :bottom, and :left
keys; omitted sides default to zero.
Resolves a renderer page-size value to a positive {width, height} point tuple.
Returns whether a four-sided margin leaves positive printable page geometry.