Skip to content

Table components

Components for creating table structures, spanning rows, and embedded figures.

RTFBody

Configures table bodies, including grouping, spanning rows, and metadata-driven pagination.

rtflite.input.RTFBody pydantic-model

RTFBody(**data)

Bases: TableAttributes

Configure table body formatting and layout.

The RTFBody component controls how data is displayed in the RTF table, including column widths, text formatting, borders, and advanced features like group_by for value suppression and subline_by for section headers.

Examples:

Basic table with custom column widths:

body = RTFBody(
    col_rel_width=[3, 2, 2, 2],
    text_justification=[["l", "c", "c", "c"]]
)

Using group_by to suppress duplicate values:

body = RTFBody(
    group_by=["SITE", "SUBJECT"],
    col_rel_width=[2, 2, 3, 1]
)

Using subline_by for section headers:

body = RTFBody(
    subline_by=["SITE", "STUDY"],  # Creates paragraph headers
    col_rel_width=[3, 2, 2]  # Note: subline_by columns are removed from table
)

Note

When using subline_by:

  • The specified columns are removed from the table display
  • Values appear as paragraph headers before each section
  • Pagination is automatically enabled (new_page=True)
  • Formatting attributes apply uniformly to the entire table
Show JSON schema:
{
  "description": "Configure table body formatting and layout.\n\nThe RTFBody component controls how data is displayed in the RTF table,\nincluding column widths, text formatting, borders, and advanced features\nlike group_by for value suppression and subline_by for section headers.\n\nExamples:\n    Basic table with custom column widths:\n    ```python\n    body = RTFBody(\n        col_rel_width=[3, 2, 2, 2],\n        text_justification=[[\"l\", \"c\", \"c\", \"c\"]]\n    )\n    ```\n\n    Using group_by to suppress duplicate values:\n    ```python\n    body = RTFBody(\n        group_by=[\"SITE\", \"SUBJECT\"],\n        col_rel_width=[2, 2, 3, 1]\n    )\n    ```\n\n    Using subline_by for section headers:\n    ```python\n    body = RTFBody(\n        subline_by=[\"SITE\", \"STUDY\"],  # Creates paragraph headers\n        col_rel_width=[3, 2, 2]  # Note: subline_by columns are removed from table\n    )\n    ```\n\nNote:\n    When using `subline_by`:\n\n    - The specified columns are removed from the table display\n    - Values appear as paragraph headers before each section\n    - Pagination is automatically enabled (`new_page=True`)\n    - Formatting attributes apply uniformly to the entire table",
  "properties": {
    "text_font": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Font number for text",
      "title": "Text Font"
    },
    "text_format": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Text formatting (e.g. 'b' for 'bold', 'i' for'italic')",
      "title": "Text Format"
    },
    "text_font_size": {
      "anyOf": [
        {
          "items": {
            "type": "number"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "number"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Font size in points",
      "title": "Text Font Size"
    },
    "text_color": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Text color name or RGB value",
      "title": "Text Color"
    },
    "text_background_color": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Background color name or RGB value",
      "title": "Text Background Color"
    },
    "text_justification": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Text alignment ('l'=left, 'c'=center, 'r'=right, 'j'=justify)",
      "title": "Text Justification"
    },
    "text_indent_first": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "First line indent in twips",
      "title": "Text Indent First"
    },
    "text_indent_left": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Left indent in twips",
      "title": "Text Indent Left"
    },
    "text_indent_right": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Right indent in twips",
      "title": "Text Indent Right"
    },
    "text_space": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Line spacing multiplier",
      "title": "Text Space"
    },
    "text_space_before": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Space before paragraph in twips",
      "title": "Text Space Before"
    },
    "text_space_after": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Space after paragraph in twips",
      "title": "Text Space After"
    },
    "text_hyphenation": {
      "anyOf": [
        {
          "items": {
            "type": "boolean"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "boolean"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Enable automatic hyphenation",
      "title": "Text Hyphenation"
    },
    "text_convert": {
      "anyOf": [
        {
          "items": {
            "type": "boolean"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "boolean"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": [
        true
      ],
      "description": "Convert LaTeX commands to Unicode characters",
      "title": "Text Convert"
    },
    "col_rel_width": {
      "anyOf": [
        {
          "items": {
            "type": "number"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Relative widths of table columns",
      "title": "Col Rel Width"
    },
    "border_left": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Left border style",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Left",
      "type": "array"
    },
    "border_right": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Right border style",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Right",
      "type": "array"
    },
    "border_top": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Top border style",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Top",
      "type": "array"
    },
    "border_bottom": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Bottom border style",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Bottom",
      "type": "array"
    },
    "border_first": {
      "default": [
        [
          ""
        ]
      ],
      "description": "First row border style",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border First",
      "type": "array"
    },
    "border_last": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Last row border style",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Last",
      "type": "array"
    },
    "border_color_left": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Left border color",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Color Left",
      "type": "array"
    },
    "border_color_right": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Right border color",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Color Right",
      "type": "array"
    },
    "border_color_top": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Top border color",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Color Top",
      "type": "array"
    },
    "border_color_bottom": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Bottom border color",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Color Bottom",
      "type": "array"
    },
    "border_color_first": {
      "default": [
        [
          ""
        ]
      ],
      "description": "First row border color",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Color First",
      "type": "array"
    },
    "border_color_last": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Last row border color",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Color Last",
      "type": "array"
    },
    "border_width": {
      "default": [
        [
          15
        ]
      ],
      "description": "Border width in twips",
      "items": {
        "items": {
          "type": "integer"
        },
        "type": "array"
      },
      "title": "Border Width",
      "type": "array"
    },
    "cell_height": {
      "default": [
        [
          0.15
        ]
      ],
      "description": "Cell height in inches",
      "items": {
        "items": {
          "type": "number"
        },
        "type": "array"
      },
      "title": "Cell Height",
      "type": "array"
    },
    "cell_justification": {
      "default": [
        [
          "l"
        ]
      ],
      "description": "Cell horizontal alignment ('l'=left, 'c'=center, 'r'=right, 'j'=justify)",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Cell Justification",
      "type": "array"
    },
    "cell_vertical_justification": {
      "default": [
        [
          "center"
        ]
      ],
      "description": "Cell vertical alignment ('top', 'center', 'bottom')",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Cell Vertical Justification",
      "type": "array"
    },
    "cell_nrow": {
      "default": [
        [
          1
        ]
      ],
      "description": "Number of rows per cell",
      "items": {
        "items": {
          "type": "integer"
        },
        "type": "array"
      },
      "title": "Cell Nrow",
      "type": "array"
    },
    "as_colheader": {
      "default": true,
      "description": "Whether to display column headers",
      "title": "As Colheader",
      "type": "boolean"
    },
    "group_by": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Column names for hierarchical value suppression. Values appear only on the first occurrence within groups, with page context restoration for multi-page tables.",
      "title": "Group By"
    },
    "page_by": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Column names to trigger page breaks when values change",
      "title": "Page By"
    },
    "new_page": {
      "default": false,
      "description": "Force a new page before the table. Automatically set to True when using subline_by.",
      "title": "New Page",
      "type": "boolean"
    },
    "pageby_header": {
      "default": true,
      "description": "Repeat column headers on new pages",
      "title": "Pageby Header",
      "type": "boolean"
    },
    "pageby_row": {
      "default": "column",
      "description": "Page break handling: 'column' (keep column) or 'first_row' (use first row as header)",
      "title": "Pageby Row",
      "type": "string"
    },
    "subline_by": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Column names to create paragraph headers. These columns are removed from the table and their values appear as section headers above each group. Forces pagination.",
      "title": "Subline By"
    },
    "last_row": {
      "default": true,
      "description": "Whether the table contains the last row of the final table",
      "title": "Last Row",
      "type": "boolean"
    }
  },
  "title": "RTFBody",
  "type": "object"
}

Config:

  • arbitrary_types_allowed: True

Fields:

  • text_font (list[int] | list[list[int]] | None)
  • text_format (list[str] | list[list[str]] | None)
  • text_font_size (list[float] | list[list[float]] | None)
  • text_color (list[str] | list[list[str]] | None)
  • text_background_color (list[str] | list[list[str]] | None)
  • text_justification (list[str] | list[list[str]] | None)
  • text_indent_first (list[int] | list[list[int]] | None)
  • text_indent_left (list[int] | list[list[int]] | None)
  • text_indent_right (list[int] | list[list[int]] | None)
  • text_space (list[int] | list[list[int]] | None)
  • text_space_before (list[int] | list[list[int]] | None)
  • text_space_after (list[int] | list[list[int]] | None)
  • text_hyphenation (list[bool] | list[list[bool]] | None)
  • text_convert (list[bool] | list[list[bool]] | None)
  • col_rel_width (list[float] | None)
  • border_left (list[list[str]])
  • border_right (list[list[str]])
  • border_top (list[list[str]])
  • border_bottom (list[list[str]])
  • border_first (list[list[str]])
  • border_last (list[list[str]])
  • border_color_left (list[list[str]])
  • border_color_right (list[list[str]])
  • border_color_top (list[list[str]])
  • border_color_bottom (list[list[str]])
  • border_color_first (list[list[str]])
  • border_color_last (list[list[str]])
  • border_width (list[list[int]])
  • cell_height (list[list[float]])
  • cell_justification (list[list[str]])
  • cell_vertical_justification (list[list[str]])
  • cell_nrow (list[list[int]])
  • as_colheader (bool)
  • group_by (Sequence[str] | None)
  • page_by (Sequence[str] | None)
  • new_page (bool)
  • pageby_header (bool)
  • pageby_row (str)
  • subline_by (Sequence[str] | None)
  • last_row (bool)

Validators:

  • convert_textgroup_by, page_by, subline_by
  • validate_pageby_rowpageby_row

as_colheader pydantic-field

as_colheader: bool = True

Whether to display column headers

group_by pydantic-field

group_by: Sequence[str] | None = None

Column names for hierarchical value suppression. Values appear only on the first occurrence within groups, with page context restoration for multi-page tables.

page_by pydantic-field

page_by: Sequence[str] | None = None

Column names to trigger page breaks when values change

new_page pydantic-field

new_page: bool = False

Force a new page before the table. Automatically set to True when using subline_by.

pageby_header pydantic-field

pageby_header: bool = True

Repeat column headers on new pages

pageby_row pydantic-field

pageby_row: str = 'column'

Page break handling: 'column' (keep column) or 'first_row' (use first row as header)

subline_by pydantic-field

subline_by: Sequence[str] | None = None

Column names to create paragraph headers. These columns are removed from the table and their values appear as section headers above each group. Forces pagination.

last_row pydantic-field

last_row: bool = True

Whether the table contains the last row of the final table

text_font pydantic-field

text_font: list[int] | list[list[int]] | None = None

Font number for text

text_format pydantic-field

text_format: list[str] | list[list[str]] | None = None

Text formatting (e.g. 'b' for 'bold', 'i' for'italic')

text_font_size pydantic-field

text_font_size: list[float] | list[list[float]] | None = None

Font size in points

text_color pydantic-field

text_color: list[str] | list[list[str]] | None = None

Text color name or RGB value

text_background_color pydantic-field

text_background_color: list[str] | list[list[str]] | None = None

Background color name or RGB value

text_justification pydantic-field

text_justification: list[str] | list[list[str]] | None = None

Text alignment ('l'=left, 'c'=center, 'r'=right, 'j'=justify)

text_indent_first pydantic-field

text_indent_first: list[int] | list[list[int]] | None = None

First line indent in twips

text_indent_left pydantic-field

text_indent_left: list[int] | list[list[int]] | None = None

Left indent in twips

text_indent_right pydantic-field

text_indent_right: list[int] | list[list[int]] | None = None

Right indent in twips

text_space pydantic-field

text_space: list[int] | list[list[int]] | None = None

Line spacing multiplier

text_space_before pydantic-field

text_space_before: list[int] | list[list[int]] | None = None

Space before paragraph in twips

text_space_after pydantic-field

text_space_after: list[int] | list[list[int]] | None = None

Space after paragraph in twips

text_hyphenation pydantic-field

text_hyphenation: list[bool] | list[list[bool]] | None = None

Enable automatic hyphenation

text_convert pydantic-field

text_convert: list[bool] | list[list[bool]] | None = [True]

Convert LaTeX commands to Unicode characters

col_rel_width pydantic-field

col_rel_width: list[float] | None = None

Relative widths of table columns

border_left pydantic-field

border_left: list[list[str]] = [['']]

Left border style

border_right pydantic-field

border_right: list[list[str]] = [['']]

Right border style

border_top pydantic-field

border_top: list[list[str]] = [['']]

Top border style

border_bottom pydantic-field

border_bottom: list[list[str]] = [['']]

Bottom border style

border_first pydantic-field

border_first: list[list[str]] = [['']]

First row border style

border_last pydantic-field

border_last: list[list[str]] = [['']]

Last row border style

border_color_left pydantic-field

border_color_left: list[list[str]] = [['']]

Left border color

border_color_right pydantic-field

border_color_right: list[list[str]] = [['']]

Right border color

border_color_top pydantic-field

border_color_top: list[list[str]] = [['']]

Top border color

border_color_bottom pydantic-field

border_color_bottom: list[list[str]] = [['']]

Bottom border color

border_color_first pydantic-field

border_color_first: list[list[str]] = [['']]

First row border color

border_color_last pydantic-field

border_color_last: list[list[str]] = [['']]

Last row border color

border_width pydantic-field

border_width: list[list[int]] = [[15]]

Border width in twips

cell_height pydantic-field

cell_height: list[list[float]] = [[0.15]]

Cell height in inches

cell_justification pydantic-field

cell_justification: list[list[str]] = [['l']]

Cell horizontal alignment ('l'=left, 'c'=center, 'r'=right, 'j'=justify)

cell_vertical_justification pydantic-field

cell_vertical_justification: list[list[str]] = [['center']]

Cell vertical alignment ('top', 'center', 'bottom')

cell_nrow pydantic-field

cell_nrow: list[list[int]] = [[1]]

Number of rows per cell

convert_to_list

convert_to_list(v)

Convert single values to lists before validation.

calculate_lines

calculate_lines(text: str, available_width: float, row_idx: int = 0, col_idx: int = 0) -> int

Calculate number of lines needed for text given available width.

Parameters:

Name Type Description Default
text str

Text content to measure

required
available_width float

Available width in inches

required
row_idx int

Row index for attribute lookup (default: 0)

0
col_idx int

Column index for attribute lookup (default: 0)

0

Returns:

Type Description
int

Number of lines needed (minimum 1)

validate_border

validate_border(v)

Validate that all border styles are valid.

RTFColumnHeader

Column header definitions. Supports multi-row headers via nested sequences.

rtflite.input.RTFColumnHeader pydantic-model

RTFColumnHeader(**data)

Bases: TableAttributes

Configure column headers for RTF tables.

The RTFColumnHeader component defines column headers that appear at the top of tables and repeat on each page in multi-page documents. Supports multi-row headers and flexible column spanning.

Examples:

Simple column headers:

header = RTFColumnHeader(
    text=["Name", "Age", "Treatment", "Response"]
)

Headers with custom formatting:

header = RTFColumnHeader(
    text=["Subject", "Baseline", "Week 4", "Week 8"],
    text_format=["b", "b", "b", "b"],  # All bold
    text_justification=["l", "c", "c", "c"],  # Left, center, center, center
    border_bottom=["double", "double", "double", "double"]
)

Multi-row headers with col_rel_width:

# First row spans multiple columns
header1 = RTFColumnHeader(
    text=["Patient Info", "Treatment Results"],
    col_rel_width=[2, 3]  # Spans 2 and 3 columns respectively
)
# Second row with individual columns
header2 = RTFColumnHeader(
    text=["ID", "Age", "Drug A", "Drug B", "Placebo"],
    col_rel_width=[1, 1, 1, 1, 1]
)

Note
  • Headers automatically repeat on each page in multi-page documents
  • Use col_rel_width to create spanning headers
  • Border styles from RTFPage are applied to the first row
Show JSON schema:
{
  "description": "Configure column headers for RTF tables.\n\nThe RTFColumnHeader component defines column headers that appear at the\ntop of tables and repeat on each page in multi-page documents. Supports\nmulti-row headers and flexible column spanning.\n\nExamples:\n    Simple column headers:\n    ```python\n    header = RTFColumnHeader(\n        text=[\"Name\", \"Age\", \"Treatment\", \"Response\"]\n    )\n    ```\n\n    Headers with custom formatting:\n    ```python\n    header = RTFColumnHeader(\n        text=[\"Subject\", \"Baseline\", \"Week 4\", \"Week 8\"],\n        text_format=[\"b\", \"b\", \"b\", \"b\"],  # All bold\n        text_justification=[\"l\", \"c\", \"c\", \"c\"],  # Left, center, center, center\n        border_bottom=[\"double\", \"double\", \"double\", \"double\"]\n    )\n    ```\n\n    Multi-row headers with col_rel_width:\n    ```python\n    # First row spans multiple columns\n    header1 = RTFColumnHeader(\n        text=[\"Patient Info\", \"Treatment Results\"],\n        col_rel_width=[2, 3]  # Spans 2 and 3 columns respectively\n    )\n    # Second row with individual columns\n    header2 = RTFColumnHeader(\n        text=[\"ID\", \"Age\", \"Drug A\", \"Drug B\", \"Placebo\"],\n        col_rel_width=[1, 1, 1, 1, 1]\n    )\n    ```\n\nNote:\n    - Headers automatically repeat on each page in multi-page documents\n    - Use `col_rel_width` to create spanning headers\n    - Border styles from `RTFPage` are applied to the first row",
  "properties": {
    "text_font": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Font number for text",
      "title": "Text Font"
    },
    "text_format": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Text formatting (e.g. 'b' for 'bold', 'i' for'italic')",
      "title": "Text Format"
    },
    "text_font_size": {
      "anyOf": [
        {
          "items": {
            "type": "number"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "number"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Font size in points",
      "title": "Text Font Size"
    },
    "text_color": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Text color name or RGB value",
      "title": "Text Color"
    },
    "text_background_color": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Background color name or RGB value",
      "title": "Text Background Color"
    },
    "text_justification": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Text alignment ('l'=left, 'c'=center, 'r'=right, 'j'=justify)",
      "title": "Text Justification"
    },
    "text_indent_first": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "First line indent in twips",
      "title": "Text Indent First"
    },
    "text_indent_left": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Left indent in twips",
      "title": "Text Indent Left"
    },
    "text_indent_right": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Right indent in twips",
      "title": "Text Indent Right"
    },
    "text_space": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Line spacing multiplier",
      "title": "Text Space"
    },
    "text_space_before": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Space before paragraph in twips",
      "title": "Text Space Before"
    },
    "text_space_after": {
      "anyOf": [
        {
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "integer"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Space after paragraph in twips",
      "title": "Text Space After"
    },
    "text_hyphenation": {
      "anyOf": [
        {
          "items": {
            "type": "boolean"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "boolean"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Enable automatic hyphenation",
      "title": "Text Hyphenation"
    },
    "text_convert": {
      "anyOf": [
        {
          "items": {
            "type": "boolean"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "type": "boolean"
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": [
        true
      ],
      "description": "Convert LaTeX commands to Unicode characters",
      "title": "Text Convert"
    },
    "col_rel_width": {
      "anyOf": [
        {
          "items": {
            "type": "number"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Relative widths of table columns",
      "title": "Col Rel Width"
    },
    "border_left": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Left border style",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Left",
      "type": "array"
    },
    "border_right": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Right border style",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Right",
      "type": "array"
    },
    "border_top": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Top border style",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Top",
      "type": "array"
    },
    "border_bottom": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Bottom border style",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Bottom",
      "type": "array"
    },
    "border_first": {
      "default": [
        [
          ""
        ]
      ],
      "description": "First row border style",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border First",
      "type": "array"
    },
    "border_last": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Last row border style",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Last",
      "type": "array"
    },
    "border_color_left": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Left border color",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Color Left",
      "type": "array"
    },
    "border_color_right": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Right border color",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Color Right",
      "type": "array"
    },
    "border_color_top": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Top border color",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Color Top",
      "type": "array"
    },
    "border_color_bottom": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Bottom border color",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Color Bottom",
      "type": "array"
    },
    "border_color_first": {
      "default": [
        [
          ""
        ]
      ],
      "description": "First row border color",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Color First",
      "type": "array"
    },
    "border_color_last": {
      "default": [
        [
          ""
        ]
      ],
      "description": "Last row border color",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Border Color Last",
      "type": "array"
    },
    "border_width": {
      "default": [
        [
          15
        ]
      ],
      "description": "Border width in twips",
      "items": {
        "items": {
          "type": "integer"
        },
        "type": "array"
      },
      "title": "Border Width",
      "type": "array"
    },
    "cell_height": {
      "default": [
        [
          0.15
        ]
      ],
      "description": "Cell height in inches",
      "items": {
        "items": {
          "type": "number"
        },
        "type": "array"
      },
      "title": "Cell Height",
      "type": "array"
    },
    "cell_justification": {
      "default": [
        [
          "l"
        ]
      ],
      "description": "Cell horizontal alignment ('l'=left, 'c'=center, 'r'=right, 'j'=justify)",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Cell Justification",
      "type": "array"
    },
    "cell_vertical_justification": {
      "default": [
        [
          "center"
        ]
      ],
      "description": "Cell vertical alignment ('top', 'center', 'bottom')",
      "items": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "title": "Cell Vertical Justification",
      "type": "array"
    },
    "cell_nrow": {
      "default": [
        [
          1
        ]
      ],
      "description": "Number of rows per cell",
      "items": {
        "items": {
          "type": "integer"
        },
        "type": "array"
      },
      "title": "Cell Nrow",
      "type": "array"
    },
    "text": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Column header text. List of strings, one per column.",
      "title": "Text"
    }
  },
  "title": "RTFColumnHeader",
  "type": "object"
}

Config:

  • arbitrary_types_allowed: True

Fields:

  • text_font (list[int] | list[list[int]] | None)
  • text_format (list[str] | list[list[str]] | None)
  • text_font_size (list[float] | list[list[float]] | None)
  • text_color (list[str] | list[list[str]] | None)
  • text_background_color (list[str] | list[list[str]] | None)
  • text_justification (list[str] | list[list[str]] | None)
  • text_indent_first (list[int] | list[list[int]] | None)
  • text_indent_left (list[int] | list[list[int]] | None)
  • text_indent_right (list[int] | list[list[int]] | None)
  • text_space (list[int] | list[list[int]] | None)
  • text_space_before (list[int] | list[list[int]] | None)
  • text_space_after (list[int] | list[list[int]] | None)
  • text_hyphenation (list[bool] | list[list[bool]] | None)
  • text_convert (list[bool] | list[list[bool]] | None)
  • col_rel_width (list[float] | None)
  • border_left (list[list[str]])
  • border_right (list[list[str]])
  • border_top (list[list[str]])
  • border_bottom (list[list[str]])
  • border_first (list[list[str]])
  • border_last (list[list[str]])
  • border_color_left (list[list[str]])
  • border_color_right (list[list[str]])
  • border_color_top (list[list[str]])
  • border_color_bottom (list[list[str]])
  • border_color_first (list[list[str]])
  • border_color_last (list[list[str]])
  • border_width (list[list[int]])
  • cell_height (list[list[float]])
  • cell_justification (list[list[str]])
  • cell_vertical_justification (list[list[str]])
  • cell_nrow (list[list[int]])
  • text (Sequence[str] | None)

Validators:

  • convert_text_beforetext
  • convert_text_aftertext

text pydantic-field

text: Sequence[str] | None = None

Column header text. List of strings, one per column.

text_font pydantic-field

text_font: list[int] | list[list[int]] | None = None

Font number for text

text_format pydantic-field

text_format: list[str] | list[list[str]] | None = None

Text formatting (e.g. 'b' for 'bold', 'i' for'italic')

text_font_size pydantic-field

text_font_size: list[float] | list[list[float]] | None = None

Font size in points

text_color pydantic-field

text_color: list[str] | list[list[str]] | None = None

Text color name or RGB value

text_background_color pydantic-field

text_background_color: list[str] | list[list[str]] | None = None

Background color name or RGB value

text_justification pydantic-field

text_justification: list[str] | list[list[str]] | None = None

Text alignment ('l'=left, 'c'=center, 'r'=right, 'j'=justify)

text_indent_first pydantic-field

text_indent_first: list[int] | list[list[int]] | None = None

First line indent in twips

text_indent_left pydantic-field

text_indent_left: list[int] | list[list[int]] | None = None

Left indent in twips

text_indent_right pydantic-field

text_indent_right: list[int] | list[list[int]] | None = None

Right indent in twips

text_space pydantic-field

text_space: list[int] | list[list[int]] | None = None

Line spacing multiplier

text_space_before pydantic-field

text_space_before: list[int] | list[list[int]] | None = None

Space before paragraph in twips

text_space_after pydantic-field

text_space_after: list[int] | list[list[int]] | None = None

Space after paragraph in twips

text_hyphenation pydantic-field

text_hyphenation: list[bool] | list[list[bool]] | None = None

Enable automatic hyphenation

text_convert pydantic-field

text_convert: list[bool] | list[list[bool]] | None = [True]

Convert LaTeX commands to Unicode characters

col_rel_width pydantic-field

col_rel_width: list[float] | None = None

Relative widths of table columns

border_left pydantic-field

border_left: list[list[str]] = [['']]

Left border style

border_right pydantic-field

border_right: list[list[str]] = [['']]

Right border style

border_top pydantic-field

border_top: list[list[str]] = [['']]

Top border style

border_bottom pydantic-field

border_bottom: list[list[str]] = [['']]

Bottom border style

border_first pydantic-field

border_first: list[list[str]] = [['']]

First row border style

border_last pydantic-field

border_last: list[list[str]] = [['']]

Last row border style

border_color_left pydantic-field

border_color_left: list[list[str]] = [['']]

Left border color

border_color_right pydantic-field

border_color_right: list[list[str]] = [['']]

Right border color

border_color_top pydantic-field

border_color_top: list[list[str]] = [['']]

Top border color

border_color_bottom pydantic-field

border_color_bottom: list[list[str]] = [['']]

Bottom border color

border_color_first pydantic-field

border_color_first: list[list[str]] = [['']]

First row border color

border_color_last pydantic-field

border_color_last: list[list[str]] = [['']]

Last row border color

border_width pydantic-field

border_width: list[list[int]] = [[15]]

Border width in twips

cell_height pydantic-field

cell_height: list[list[float]] = [[0.15]]

Cell height in inches

cell_justification pydantic-field

cell_justification: list[list[str]] = [['l']]

Cell horizontal alignment ('l'=left, 'c'=center, 'r'=right, 'j'=justify)

cell_vertical_justification pydantic-field

cell_vertical_justification: list[list[str]] = [['center']]

Cell vertical alignment ('top', 'center', 'bottom')

cell_nrow pydantic-field

cell_nrow: list[list[int]] = [[1]]

Number of rows per cell

convert_to_list

convert_to_list(v)

Convert single values to lists before validation.

calculate_lines

calculate_lines(text: str, available_width: float, row_idx: int = 0, col_idx: int = 0) -> int

Calculate number of lines needed for text given available width.

Parameters:

Name Type Description Default
text str

Text content to measure

required
available_width float

Available width in inches

required
row_idx int

Row index for attribute lookup (default: 0)

0
col_idx int

Column index for attribute lookup (default: 0)

0

Returns:

Type Description
int

Number of lines needed (minimum 1)

validate_border

validate_border(v)

Validate that all border styles are valid.

RTFFigure

Embeds figures and images alongside or in place of tabular content.

rtflite.input.RTFFigure pydantic-model

Bases: BaseModel

RTF Figure component for embedding images in RTF documents.

This class handles figure embedding with support for multiple images, custom sizing, and proper RTF encoding.

Show JSON schema:
{
  "description": "RTF Figure component for embedding images in RTF documents.\n\nThis class handles figure embedding with support for multiple images,\ncustom sizing, and proper RTF encoding.",
  "properties": {
    "figures": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "format": "path",
          "type": "string"
        },
        {
          "items": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "format": "path",
                "type": "string"
              }
            ]
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Image file path(s)-single path or list of paths to PNG, JPEG, or EMF files",
      "title": "Figures"
    },
    "fig_height": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "items": {
            "type": "number"
          },
          "type": "array"
        }
      ],
      "default": 5.0,
      "description": "Height of figures in inches (single value or list)",
      "title": "Fig Height"
    },
    "fig_width": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "items": {
            "type": "number"
          },
          "type": "array"
        }
      ],
      "default": 5.0,
      "description": "Width of figures in inches (single value or list)",
      "title": "Fig Width"
    },
    "fig_align": {
      "default": "center",
      "description": "Horizontal alignment of figures ('left', 'center', 'right')",
      "title": "Fig Align",
      "type": "string"
    },
    "fig_pos": {
      "default": "after",
      "description": "Position relative to table content ('before' or 'after')",
      "title": "Fig Pos",
      "type": "string"
    }
  },
  "title": "RTFFigure",
  "type": "object"
}

Config:

  • arbitrary_types_allowed: True

Fields:

  • figures (str | Path | list[str | Path] | None)
  • fig_height (float | list[float])
  • fig_width (float | list[float])
  • fig_align (str)
  • fig_pos (str)

Validators:

  • convert_dimensionsfig_height, fig_width
  • validate_alignmentfig_align
  • validate_positionfig_pos
  • validate_figure_data

figures pydantic-field

figures: str | Path | list[str | Path] | None = None

Image file path(s)-single path or list of paths to PNG, JPEG, or EMF files

fig_height pydantic-field

fig_height: float | list[float] = 5.0

Height of figures in inches (single value or list)

fig_width pydantic-field

fig_width: float | list[float] = 5.0

Width of figures in inches (single value or list)

fig_align pydantic-field

fig_align: str = 'center'

Horizontal alignment of figures ('left', 'center', 'right')

fig_pos pydantic-field

fig_pos: str = 'after'

Position relative to table content ('before' or 'after')

convert_dimensions pydantic-validator

convert_dimensions(v)

Convert single value to list if needed.

validate_alignment pydantic-validator

validate_alignment(v)

Validate figure alignment value.

validate_position pydantic-validator

validate_position(v)

Validate figure position value.

validate_figure_data pydantic-validator

validate_figure_data()

Validate figure paths and convert to list format.

Row components

Lower-level components for constructing rows and cells manually when needed.

Row

rtflite.row.Row pydantic-model

Bases: BaseModel

Represents a row in an RTF table.

Show JSON schema:
{
  "$defs": {
    "Border": {
      "description": "Represents a single border's style, color, and width.",
      "properties": {
        "style": {
          "default": "single",
          "description": "Border style (single, double, dashed, etc)",
          "title": "Style",
          "type": "string"
        },
        "width": {
          "default": 15,
          "description": "Border width in twips",
          "title": "Width",
          "type": "integer"
        },
        "color": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Border color",
          "title": "Color"
        }
      },
      "title": "Border",
      "type": "object"
    },
    "Cell": {
      "description": "Represents a cell in an RTF table.",
      "properties": {
        "text": {
          "$ref": "#/$defs/TextContent"
        },
        "width": {
          "description": "Cell width",
          "title": "Width",
          "type": "number"
        },
        "vertical_justification": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": "bottom",
          "description": "Vertical alignment",
          "title": "Vertical Justification"
        },
        "border_top": {
          "anyOf": [
            {
              "$ref": "#/$defs/Border"
            },
            {
              "type": "null"
            }
          ],
          "default": {
            "style": "single",
            "width": 15,
            "color": null
          },
          "description": "Top border"
        },
        "border_right": {
          "anyOf": [
            {
              "$ref": "#/$defs/Border"
            },
            {
              "type": "null"
            }
          ],
          "default": {
            "style": "single",
            "width": 15,
            "color": null
          },
          "description": "Right border"
        },
        "border_bottom": {
          "anyOf": [
            {
              "$ref": "#/$defs/Border"
            },
            {
              "type": "null"
            }
          ],
          "default": {
            "style": "single",
            "width": 15,
            "color": null
          },
          "description": "Bottom border"
        },
        "border_left": {
          "anyOf": [
            {
              "$ref": "#/$defs/Border"
            },
            {
              "type": "null"
            }
          ],
          "default": {
            "style": "single",
            "width": 15,
            "color": null
          },
          "description": "Left border"
        }
      },
      "required": [
        "text",
        "width"
      ],
      "title": "Cell",
      "type": "object"
    },
    "TextContent": {
      "description": "Represents RTF text with formatting.",
      "properties": {
        "text": {
          "description": "The text content",
          "title": "Text",
          "type": "string"
        },
        "font": {
          "default": 1,
          "description": "Font index",
          "title": "Font",
          "type": "integer"
        },
        "size": {
          "default": 9,
          "description": "Font size",
          "title": "Size",
          "type": "integer"
        },
        "format": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Text formatting codes: b=bold, i=italic, u=underline, s=strikethrough, ^=superscript, _=subscript",
          "title": "Format"
        },
        "color": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Text color",
          "title": "Color"
        },
        "background_color": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Background color",
          "title": "Background Color"
        },
        "justification": {
          "default": "l",
          "description": "Text justification (l, c, r, d, j)",
          "title": "Justification",
          "type": "string"
        },
        "indent_first": {
          "default": 0,
          "description": "First line indent",
          "title": "Indent First",
          "type": "integer"
        },
        "indent_left": {
          "default": 0,
          "description": "Left indent",
          "title": "Indent Left",
          "type": "integer"
        },
        "indent_right": {
          "default": 0,
          "description": "Right indent",
          "title": "Indent Right",
          "type": "integer"
        },
        "space": {
          "default": 1,
          "description": "Line spacing",
          "title": "Space",
          "type": "integer"
        },
        "space_before": {
          "default": 15,
          "description": "Space before paragraph",
          "title": "Space Before",
          "type": "integer"
        },
        "space_after": {
          "default": 15,
          "description": "Space after paragraph",
          "title": "Space After",
          "type": "integer"
        },
        "convert": {
          "default": true,
          "description": "Enable LaTeX to Unicode conversion",
          "title": "Convert",
          "type": "boolean"
        },
        "hyphenation": {
          "default": true,
          "description": "Enable hyphenation",
          "title": "Hyphenation",
          "type": "boolean"
        }
      },
      "required": [
        "text"
      ],
      "title": "TextContent",
      "type": "object"
    }
  },
  "description": "Represents a row in an RTF table.",
  "properties": {
    "row_cells": {
      "description": "List of cells in the row",
      "items": {
        "$ref": "#/$defs/Cell"
      },
      "title": "Row Cells",
      "type": "array"
    },
    "justification": {
      "default": "c",
      "description": "Row justification (l, c, r)",
      "title": "Justification",
      "type": "string"
    },
    "height": {
      "default": 0.15,
      "description": "Row height",
      "title": "Height",
      "type": "number"
    }
  },
  "required": [
    "row_cells"
  ],
  "title": "Row",
  "type": "object"
}

Fields:

  • row_cells (Sequence[Cell])
  • justification (str)
  • height (float)

row_cells pydantic-field

row_cells: Sequence[Cell]

List of cells in the row

justification pydantic-field

justification: str = 'c'

Row justification (l, c, r)

height pydantic-field

height: float = 0.15

Row height

Cell

rtflite.row.Cell pydantic-model

Bases: BaseModel

Represents a cell in an RTF table.

Show JSON schema:
{
  "$defs": {
    "Border": {
      "description": "Represents a single border's style, color, and width.",
      "properties": {
        "style": {
          "default": "single",
          "description": "Border style (single, double, dashed, etc)",
          "title": "Style",
          "type": "string"
        },
        "width": {
          "default": 15,
          "description": "Border width in twips",
          "title": "Width",
          "type": "integer"
        },
        "color": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Border color",
          "title": "Color"
        }
      },
      "title": "Border",
      "type": "object"
    },
    "TextContent": {
      "description": "Represents RTF text with formatting.",
      "properties": {
        "text": {
          "description": "The text content",
          "title": "Text",
          "type": "string"
        },
        "font": {
          "default": 1,
          "description": "Font index",
          "title": "Font",
          "type": "integer"
        },
        "size": {
          "default": 9,
          "description": "Font size",
          "title": "Size",
          "type": "integer"
        },
        "format": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Text formatting codes: b=bold, i=italic, u=underline, s=strikethrough, ^=superscript, _=subscript",
          "title": "Format"
        },
        "color": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Text color",
          "title": "Color"
        },
        "background_color": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Background color",
          "title": "Background Color"
        },
        "justification": {
          "default": "l",
          "description": "Text justification (l, c, r, d, j)",
          "title": "Justification",
          "type": "string"
        },
        "indent_first": {
          "default": 0,
          "description": "First line indent",
          "title": "Indent First",
          "type": "integer"
        },
        "indent_left": {
          "default": 0,
          "description": "Left indent",
          "title": "Indent Left",
          "type": "integer"
        },
        "indent_right": {
          "default": 0,
          "description": "Right indent",
          "title": "Indent Right",
          "type": "integer"
        },
        "space": {
          "default": 1,
          "description": "Line spacing",
          "title": "Space",
          "type": "integer"
        },
        "space_before": {
          "default": 15,
          "description": "Space before paragraph",
          "title": "Space Before",
          "type": "integer"
        },
        "space_after": {
          "default": 15,
          "description": "Space after paragraph",
          "title": "Space After",
          "type": "integer"
        },
        "convert": {
          "default": true,
          "description": "Enable LaTeX to Unicode conversion",
          "title": "Convert",
          "type": "boolean"
        },
        "hyphenation": {
          "default": true,
          "description": "Enable hyphenation",
          "title": "Hyphenation",
          "type": "boolean"
        }
      },
      "required": [
        "text"
      ],
      "title": "TextContent",
      "type": "object"
    }
  },
  "description": "Represents a cell in an RTF table.",
  "properties": {
    "text": {
      "$ref": "#/$defs/TextContent"
    },
    "width": {
      "description": "Cell width",
      "title": "Width",
      "type": "number"
    },
    "vertical_justification": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": "bottom",
      "description": "Vertical alignment",
      "title": "Vertical Justification"
    },
    "border_top": {
      "anyOf": [
        {
          "$ref": "#/$defs/Border"
        },
        {
          "type": "null"
        }
      ],
      "default": {
        "style": "single",
        "width": 15,
        "color": null
      },
      "description": "Top border"
    },
    "border_right": {
      "anyOf": [
        {
          "$ref": "#/$defs/Border"
        },
        {
          "type": "null"
        }
      ],
      "default": {
        "style": "single",
        "width": 15,
        "color": null
      },
      "description": "Right border"
    },
    "border_bottom": {
      "anyOf": [
        {
          "$ref": "#/$defs/Border"
        },
        {
          "type": "null"
        }
      ],
      "default": {
        "style": "single",
        "width": 15,
        "color": null
      },
      "description": "Bottom border"
    },
    "border_left": {
      "anyOf": [
        {
          "$ref": "#/$defs/Border"
        },
        {
          "type": "null"
        }
      ],
      "default": {
        "style": "single",
        "width": 15,
        "color": null
      },
      "description": "Left border"
    }
  },
  "required": [
    "text",
    "width"
  ],
  "title": "Cell",
  "type": "object"
}

Fields:

  • text (TextContent)
  • width (float)
  • vertical_justification (str | None)
  • border_top (Border | None)
  • border_right (Border | None)
  • border_bottom (Border | None)
  • border_left (Border | None)

width pydantic-field

width: float

Cell width

vertical_justification pydantic-field

vertical_justification: str | None = 'bottom'

Vertical alignment

border_top pydantic-field

border_top: Border | None = Border()

Top border

border_right pydantic-field

border_right: Border | None = Border()

Right border

border_bottom pydantic-field

border_bottom: Border | None = Border()

Bottom border

border_left pydantic-field

border_left: Border | None = Border()

Left border

Border

rtflite.row.Border pydantic-model

Bases: BaseModel

Represents a single border's style, color, and width.

Show JSON schema:
{
  "description": "Represents a single border's style, color, and width.",
  "properties": {
    "style": {
      "default": "single",
      "description": "Border style (single, double, dashed, etc)",
      "title": "Style",
      "type": "string"
    },
    "width": {
      "default": 15,
      "description": "Border width in twips",
      "title": "Width",
      "type": "integer"
    },
    "color": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Border color",
      "title": "Color"
    }
  },
  "title": "Border",
  "type": "object"
}

Fields:

  • style (str)
  • width (int)
  • color (str | None)

style pydantic-field

style: str = 'single'

Border style (single, double, dashed, etc)

width pydantic-field

width: int = DEFAULT_BORDER_WIDTH

Border width in twips

color pydantic-field

color: str | None = None

Border color