View Source Idmlx.Components.Pages behaviour (idmlx v0.2.1)

Provides functionality for parsing and working with InDesign pages.

This module handles:

  • Page parsing from XML
  • Geometric calculations
  • Item placement and transformation
  • Page orientation determination

Page Processing

Pages are processed by:

  1. Extracting geometric bounds and transforms
  2. Calculating actual coordinates
  3. Determining page orientation
  4. Collecting and transforming page items

Coordinate System

The coordinate system uses:

  • Origin at top-left
  • Positive X to the right
  • Positive Y downward
  • Units in points (1/72 inch)

Summary

Functions

Determines if an element is positioned within a page's boundaries.

Parses a page from an XML fragment.

Callbacks

parse_page(t)

@callback parse_page(SweetXml.t()) :: Idmlx.Components.Page.t()

Functions

element_is_in_page(element, coordinates)

@spec element_is_in_page(SweetXml.t(), Idmlx.Components.Page.coordinates()) ::
  boolean()

Determines if an element is positioned within a page's boundaries.

Parameters

  • element: The element to check
  • coordinates: The page coordinates to check against

Returns

Boolean indicating if the element is within the page

Examples

iex> element = get_element()
iex> coordinates = %{"x1" => 0.0, "x2" => 595.28}
iex> Idmlx.Components.Pages.element_is_in_page(element, coordinates)
true

parse_page(xml_fragment)

@spec parse_page(SweetXml.t()) :: Idmlx.Components.Page.t()

Parses a page from an XML fragment.

Processes the page geometry, transforms, and content to create a complete page representation.

Parameters

  • xml_fragment: XML fragment containing page data

Returns

A Page struct with all calculated properties

Examples

iex> xml = get_page_xml()
iex> Idmlx.Components.Pages.parse_page(xml)
%Page{
  geometric_bounds: [0.0, 0.0, 841.89, 595.28],
  face: "RECTO",
  items: [%TextFrame{}, %Rectangle{}]
}