View Source Idmlx.Components.TextFrame (idmlx v0.2.1)

Represents a text frame in an InDesign document.

This module provides functionality for handling text frames, including:

  • Content management
  • Style application
  • Geometric properties
  • HTML conversion
  • Layout preferences

Text Frame Structure

  • name - Unique identifier for the text frame
  • layer - Layer containing the text frame
  • content - Text content from associated story
  • content_type - Type of content (e.g., "TextType")
  • object_style - Applied object style reference
  • paragraph_style - Applied paragraph style reference
  • item_transform - Transformation matrix [a, b, c, d, tx, ty]
  • coordinates - Bounding box coordinates
  • dimensions - Width and height
  • editable - Whether the frame is editable
  • attributes - Raw XML attributes
  • preferences - Text frame preferences
  • story - Associated story content

Examples

%Idmlx.Components.TextFrame{
  name: "text_frame_1",
  content_type: "TextType",
  coordinates: %{"x1" => 0.0, "y1" => 0.0, "x2" => 200.0, "y2" => 100.0},
  dimensions: %{"width" => 200.0, "height" => 100.0},
  content: "Sample text content"
}

Summary

Functions

Gets text frame preferences from XML.

Parses a text frame element from an XML fragment.

Converts a text frame to HTML representation.

Types

coordinates()

@type coordinates() :: %{required(String.t()) => float()}

dimensions()

@type dimensions() :: %{required(String.t()) => float()}

t()

@type t() :: %Idmlx.Components.TextFrame{
  attributes: [map()] | nil,
  content: String.t() | nil,
  content_type: String.t() | nil,
  coordinates: coordinates() | nil,
  dimensions: dimensions() | nil,
  editable: boolean() | nil,
  item_transform: [float()] | nil,
  layer: any() | nil,
  name: String.t() | nil,
  object_style: String.t() | nil,
  paragraph_style: any() | nil,
  preferences: [map()] | nil,
  story: Idmlx.Components.Story.t() | nil
}

Functions

get_text_frame_preferences(xml_fragment)

@spec get_text_frame_preferences(SweetXml.t()) :: [map()]

Gets text frame preferences from XML.

Parameters

  • xml_fragment: XML fragment containing preferences

Returns

List of preference attributes

parse(xml_fragment, layer \\ nil, story \\ nil)

@spec parse(SweetXml.t(), any(), Idmlx.Components.Story.t() | nil) :: t()

Parses a text frame element from an XML fragment.

Processes the text frame geometry, content, and attributes to create a complete text frame representation.

Parameters

  • xml_fragment: XML fragment containing text frame data
  • layer: Optional layer information
  • story: Optional associated story content

Returns

A TextFrame struct with calculated properties

Examples

iex> xml = get_text_frame_xml()
iex> TextFrame.parse(xml)
%TextFrame{
  name: "text_frame_1",
  content_type: "TextType",
  coordinates: %{"x1" => 0.0, "y1" => 0.0, "x2" => 200.0, "y2" => 100.0}
}

to_html(element, assigned_content, mode)

@spec to_html(t(), String.t() | nil, atom()) :: String.t()

Converts a text frame to HTML representation.

Creates an HTML div element with appropriate styling and positioning based on the text frame's properties and styles.

Parameters

  • element: The TextFrame struct to convert
  • assigned_content: Optional content override
  • mode: Rendering mode

Returns

HTML string representation of the text frame

Examples

iex> frame = %TextFrame{content: "Hello", coordinates: %{"x1" => 0, "y1" => 0}}
iex> TextFrame.to_html(frame, nil, :filled)
"""
<div class="style1" style="position: absolute; left: 0px; top: 0px;">
  Hello
</div>
"""