Skip to content

API reference

rtflite

rtflite: A Python library for creating RTF documents.

TableAttributes pydantic-model

Bases: TextAttributes

Base class for table-related attributes in RTF components

Show JSON schema:
{
  "description": "Base class for table-related attributes in RTF components",
  "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"
    }
  },
  "title": "TableAttributes",
  "type": "object"
}

Fields:

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.

LibreOfficeConverter

LibreOfficeConverter(executable_path: str | Path | None = None)

Convert RTF documents to other formats using LibreOffice.

Convert RTF files to various formats including PDF, DOCX, HTML, and others using LibreOffice in headless mode.

Requirements
  • LibreOffice 7.1 or later must be installed.
  • Automatically finds LibreOffice in standard installation paths.
  • For custom installations, provide executable_path parameter.
Note

The converter runs LibreOffice in headless mode, so no GUI is required. This makes it suitable for server environments and automated workflows.

Parameters:

Name Type Description Default
executable_path str | Path | None

Path (or executable name) to LibreOffice. If None, searches standard installation locations for each platform.

None

Raises:

Type Description
FileNotFoundError

If LibreOffice executable cannot be found.

ValueError

If LibreOffice version is below minimum requirement.

convert

convert(input_files: str | Path | Sequence[str | Path], output_dir: str | Path, format: str = 'pdf', overwrite: bool = False) -> Path | Sequence[Path]

Convert RTF file(s) to specified format using LibreOffice.

Performs the actual conversion of RTF files to the target format using LibreOffice in headless mode. Supports single file or batch conversion.

Parameters:

Name Type Description Default
input_files str | Path | Sequence[str | Path]

Path to input RTF file or list of paths. Can be string or Path object. For batch conversion, provide a list/tuple.

required
output_dir str | Path

Directory where converted files will be saved. Created if it doesn't exist. Can be string or Path object.

required
format str

Target format for conversion. Supported formats:

  • 'pdf': Portable Document Format (default)
  • 'docx': Microsoft Word (Office Open XML)
  • 'doc': Microsoft Word 97-2003
  • 'html': HTML Document
  • 'odt': OpenDocument Text
  • 'txt': Plain Text
'pdf'
overwrite bool

If True, overwrites existing files in output directory. If False, raises error if output file already exists.

False

Returns:

Type Description
Path | Sequence[Path]

Path | Sequence[Path]: For single file input, returns Path to the converted file. For multiple files, returns list of Paths.

Raises:

Type Description
FileExistsError

If output file exists and overwrite=False.

RuntimeError

If LibreOffice conversion fails.

Examples:

Single file conversion:

converter = LibreOfficeConverter()
pdf_path = converter.convert(
    "report.rtf",
    output_dir="pdfs/",
    format="pdf"
)
print(f"Created: {pdf_path}")

Batch conversion with overwrite:

rtf_files = ["report1.rtf", "report2.rtf", "report3.rtf"]
pdf_paths = converter.convert(
    input_files=rtf_files,
    output_dir="output/pdfs/",
    format="pdf",
    overwrite=True
)
for path in pdf_paths:
    print(f"Converted: {path}")

RTFConfiguration dataclass

RTFConfiguration(page: PageConfiguration, fonts: FontConfiguration, colors: ColorConfiguration, borders: BorderConfiguration, text: TextConfiguration)

Master configuration container for RTF document generation.

create_default classmethod

create_default() -> RTFConfiguration

Create default RTF configuration.

create_pharmaceutical_standard classmethod

create_pharmaceutical_standard() -> RTFConfiguration

Create configuration optimized for pharmaceutical reporting.

create_landscape classmethod

create_landscape() -> RTFConfiguration

Create landscape-oriented configuration.

RTFConstants

Core RTF constants for measurements, formatting, and control codes.

TWIPS_PER_INCH class-attribute instance-attribute

TWIPS_PER_INCH: Final[int] = 1440

Number of twips in one inch. RTF uses twips as the base unit.

POINTS_PER_INCH class-attribute instance-attribute

POINTS_PER_INCH: Final[int] = 72

Number of points in one inch.

LINE_SPACING_FACTOR class-attribute instance-attribute

LINE_SPACING_FACTOR: Final[int] = 240

Factor used for line spacing calculations in RTF.

DEFAULT_BORDER_WIDTH class-attribute instance-attribute

DEFAULT_BORDER_WIDTH: Final[int] = 15

Default border width in twips.

DEFAULT_CELL_HEIGHT class-attribute instance-attribute

DEFAULT_CELL_HEIGHT: Final[float] = 0.15

Default cell height in inches.

DEFAULT_SPACE_BEFORE class-attribute instance-attribute

DEFAULT_SPACE_BEFORE: Final[int] = 15

Default space before paragraph in points.

DEFAULT_SPACE_AFTER class-attribute instance-attribute

DEFAULT_SPACE_AFTER: Final[int] = 15

Default space after paragraph in points.

DEFAULT_FONT_SIZE class-attribute instance-attribute

DEFAULT_FONT_SIZE: Final[float] = 9

Default font size in points.

Control

RTF control word constants.

RTFDocument pydantic-model

RTFDocument(**data)

Bases: BaseModel

Main class for creating RTF documents with tables, text, and figures.

RTFDocument is the central class for generating Rich Text Format (RTF) files containing formatted tables, titles, footnotes, and other document elements. It provides a comprehensive API for creating professional documents commonly used in clinical trials, scientific research, and data reporting.

Examples:

Simple table with title:

import rtflite as rtf
import polars as pl

df = pl.DataFrame({
    "Subject": ["001", "002", "003"],
    "Age": [45, 52, 38],
    "Treatment": ["Drug A", "Drug B", "Placebo"]
})

doc = rtf.RTFDocument(
    df=df,
    rtf_title=rtf.RTFTitle(text="Patient Demographics"),
    rtf_body=rtf.RTFBody(col_rel_width=[2, 1, 2])
)
doc.write_rtf("demographics.rtf")

Multi-page document with headers and footers:

doc = rtf.RTFDocument(
    df=large_df,
    rtf_page=rtf.RTFPage(nrow=40, orientation="landscape"),
    rtf_page_header=rtf.RTFPageHeader(),  # Default page numbering
    rtf_page_footer=rtf.RTFPageFooter(text="Confidential"),
    rtf_title=rtf.RTFTitle(text="Clinical Study Results"),
    rtf_column_header=rtf.RTFColumnHeader(
        text=["Subject ID", "Visit", "Result", "Units"]
    ),
    rtf_body=rtf.RTFBody(
        col_rel_width=[2, 1, 1, 1],
        text_justification=[["l", "c", "r", "c"]]
    ),
    rtf_footnote=rtf.RTFFootnote(
        text="Results are mean +/- SD"
    )
)
doc.write_rtf("results.rtf")

Document with grouped data and sublines:

doc = rtf.RTFDocument(
    df=grouped_df,
    rtf_body=rtf.RTFBody(
        group_by=["SITE", "TREATMENT"],  # Suppress duplicate values
        subline_by=["STUDY_PHASE"],      # Create section headers
        col_rel_width=[2, 2, 1, 1]
    )
)

Attributes:

Name Type Description
df DataFrame | list[DataFrame] | None

Data to display in the table. Can be a single DataFrame or list of DataFrames for multi-section documents. Accepts pandas or polars DataFrames (automatically converted to polars internally).

rtf_page RTFPage

Page configuration including size, orientation, margins, and pagination settings.

rtf_page_header RTFPageHeader | None

Optional header appearing at the top of every page.

rtf_page_footer RTFPageFooter | None

Optional footer appearing at the bottom of every page.

rtf_title RTFTitle | None

Document title(s) displayed at the top.

rtf_column_header Sequence[RTFColumnHeader] | Sequence[Sequence[RTFColumnHeader | None]]

Column headers for the table. Can be a single header or list of headers for multi-row headers.

rtf_body RTFBody | Sequence[RTFBody] | None

Table body configuration including column widths, formatting, borders, and special features like group_by and subline_by.

rtf_footnote RTFFootnote | None

Optional footnote text displayed after the table.

rtf_source RTFSource | None

Optional source citation displayed at the very bottom.

rtf_figure RTFFigure | None

Optional figure/image to embed in the document.

Methods:

Name Description
rtf_encode

Generate the complete RTF document as a string.

write_rtf

Write the RTF document to a file.

Show JSON schema:
{
  "$defs": {
    "RTFBody": {
      "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"
    },
    "RTFColumnHeader": {
      "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"
    },
    "RTFFigure": {
      "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"
    },
    "RTFFootnote": {
      "description": "RTF footnote component for explanatory notes and citations.\n\nThe RTFFootnote component displays footnote text at the bottom of tables.\nSupports multiple footnote lines and can be rendered as a table (with borders)\nor plain text. Text conversion is enabled by default.\n\nExamples:\n    Single footnote:\n    ```python\n    footnote = RTFFootnote(\n        text=\"CI = Confidence Interval; N = Number of subjects\"\n    )\n    ```\n\n    Multiple footnotes:\n    ```python\n    footnote = RTFFootnote(\n        text=[\n            \"* p-value from ANCOVA model\",\n            \"** Missing values were imputed using LOCF\",\n            \"*** Baseline is defined as last value before first dose\"\n        ]\n    )\n    ```\n\n    Footnote without table borders:\n    ```python\n    footnote = RTFFootnote(\n        text=\"Data cutoff date: 2023-12-31\",\n        as_table=False  # No borders around footnote\n    )\n    ```\n\nNote:\n    - Multiple footnote lines are joined with \\\\line separator\n    - Text conversion is enabled by default (LaTeX symbols supported)\n    - Default rendering includes table borders (as_table=True)",
      "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": "Text content",
          "title": "Text"
        },
        "as_table": {
          "description": "Whether to render as table (True) or plain text (False)",
          "title": "As Table",
          "type": "boolean"
        }
      },
      "required": [
        "as_table"
      ],
      "title": "RTFFootnote",
      "type": "object"
    },
    "RTFPage": {
      "description": "Configure RTF page layout and pagination settings.\n\nThe RTFPage component controls page dimensions, margins, orientation,\nand pagination behavior including rows per page and border styles for\nfirst/last rows across page boundaries.\n\nExamples:\n    Basic portrait page with custom margins:\n    ```python\n    page = RTFPage(\n        orientation=\"portrait\",\n        margin=[\n            1.0,\n            1.0,\n            1.5,\n            1.0,\n            1.5,\n            1.0,\n        ],  # left, right, top, bottom, header, footer\n    )\n    ```\n\n    Landscape layout for wide tables:\n    ```python\n    page = RTFPage(\n        orientation=\"landscape\",\n        nrow=30,  # Fewer rows due to landscape\n        border_first=\"double\",  # Double border on first row\n        border_last=\"single\"    # Single border on last row\n    )\n    ```\n\nAttributes:\n    nrow: Total number of rows per page including ALL components:\n        - Column headers (if displayed)\n        - Data rows\n        - Footnotes (if present)\n        - Source lines (if present)\n        This is NOT just data rows - it's the complete row budget.\n\n    border_first: Border style for the first row of the table.\n        Defaults to \"double\" for emphasis.\n\n    border_last: Border style for the last row of the table.\n        Defaults to \"double\" for closure.\n\nNote:\n    The `nrow` parameter represents the total row capacity of a page,\n    not just data rows. Plan accordingly when setting this value.",
      "properties": {
        "orientation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": "portrait",
          "description": "Page orientation ('portrait' or 'landscape')",
          "title": "Orientation"
        },
        "width": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Page width in inches",
          "title": "Width"
        },
        "height": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Page height in inches",
          "title": "Height"
        },
        "margin": {
          "anyOf": [
            {
              "items": {
                "type": "number"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Page margins [left, right, top, bottom, header, footer] in inches",
          "title": "Margin"
        },
        "nrow": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Total rows per page including headers, data, footnotes, and sources. NOT just data rows - this is the complete page row budget.",
          "title": "Nrow"
        },
        "border_first": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": "double",
          "description": "First row border style",
          "title": "Border First"
        },
        "border_last": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": "double",
          "description": "Last row border style",
          "title": "Border Last"
        },
        "col_width": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Total width of table columns in inches",
          "title": "Col Width"
        },
        "use_color": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": false,
          "description": "Whether to use color in the document",
          "title": "Use Color"
        },
        "page_title": {
          "default": "all",
          "description": "Where to display titles in multi-page documents ('first', 'last', 'all')",
          "title": "Page Title",
          "type": "string"
        },
        "page_footnote": {
          "default": "last",
          "description": "Where to display footnotes in multi-page documents ('first', 'last', 'all')",
          "title": "Page Footnote",
          "type": "string"
        },
        "page_source": {
          "default": "last",
          "description": "Where to display source in multi-page documents ('first', 'last', 'all')",
          "title": "Page Source",
          "type": "string"
        }
      },
      "title": "RTFPage",
      "type": "object"
    },
    "RTFPageFooter": {
      "description": "RTF page footer component for document footers.\n\nThe RTFPageFooter appears at the bottom of every page, typically used for\nconfidentiality notices, timestamps, or file paths. Center-aligned by default.\n\nExamples:\n    Simple footer:\n    ```python\n    footer = RTFPageFooter(\n        text=\"Company Confidential\"\n    )\n    ```\n\n    Multi-line footer:\n    ```python\n    footer = RTFPageFooter(\n        text=[\n            \"Proprietary and Confidential\",\n            \"Do Not Distribute\"\n        ],\n        text_font_size=[8, 8]\n    )\n    ```\n\n    Footer with timestamp:\n    ```python\n    footer = RTFPageFooter(\n        text=\"Generated: 2024-01-15 14:30:00 | program.py\",\n        text_justification=[\"l\"],  # Left align\n        text_font_size=[8]\n    )\n    ```\n\nNote:\n    - Center-aligned by default\n    - Text conversion is disabled by default to preserve special characters\n    - Appears on every page of the document",
      "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"
        },
        "text": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Text content",
          "title": "Text"
        },
        "text_indent_reference": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": "table",
          "description": "Reference point for indentation ('page' or 'table')",
          "title": "Text Indent Reference"
        }
      },
      "title": "RTFPageFooter",
      "type": "object"
    },
    "RTFPageHeader": {
      "description": "RTF page header component for document headers.\n\nThe RTFPageHeader appears at the top of every page, typically used for\npage numbering, document titles, or study identifiers. Right-aligned by\ndefault with automatic page numbering.\n\nExamples:\n    Default page numbering:\n    ```python\n    header = RTFPageHeader()  # Shows \"Page X of Y\"\n    ```\n\n    Custom header text:\n    ```python\n    header = RTFPageHeader(\n        text=\"Protocol ABC-123 | Confidential\",\n        text_justification=[\"c\"]  # Center align\n    )\n    ```\n\n    Header with page number:\n    ```python\n    header = RTFPageHeader(\n        text=\"Study Report - Page \\\\chpgn\",  # Current page number\n        text_format=[\"b\"],  # Bold\n        text_font_size=[10]\n    )\n    ```\n\nNote:\n    - Default text is \"Page \\\\chpgn of {\\\\field{\\\\*\\\\fldinst NUMPAGES }}\"\n    - Text conversion is disabled by default to preserve RTF field codes\n    - Right-aligned by default",
      "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"
        },
        "text": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Text content",
          "title": "Text"
        },
        "text_indent_reference": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": "table",
          "description": "Reference point for indentation ('page' or 'table')",
          "title": "Text Indent Reference"
        }
      },
      "title": "RTFPageHeader",
      "type": "object"
    },
    "RTFSource": {
      "description": "RTF source component for data source citations.\n\nThe RTFSource component displays source information at the very bottom\nof the document. Typically used for dataset names, program references,\nor generation timestamps. Rendered as plain text without borders by default.\n\nExamples:\n    Simple source citation:\n    ```python\n    source = RTFSource(\n        text=\"Source: ADAE dataset, generated 2024-01-15\"\n    )\n    ```\n\n    Multiple source lines:\n    ```python\n    source = RTFSource(\n        text=[\n            \"Dataset: ADAE version 3.0\",\n            \"Program: ae_summary.py\",\n            \"Generated: 2024-01-15 14:30:00\"\n        ]\n    )\n    ```\n\n    Source with table borders:\n    ```python\n    source = RTFSource(\n        text=\"Database lock: 2023-12-31\",\n        as_table=True,  # Add borders around source\n        text_justification=[[\"l\"]]  # Left align instead of center\n    )\n    ```\n\nNote:\n    - Center-aligned by default\n    - Rendered without borders by default (as_table=False)\n    - Text conversion is enabled by default",
      "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": "Text content",
          "title": "Text"
        },
        "as_table": {
          "description": "Whether to render as table (True) or plain text (False)",
          "title": "As Table",
          "type": "boolean"
        }
      },
      "required": [
        "as_table"
      ],
      "title": "RTFSource",
      "type": "object"
    },
    "RTFSubline": {
      "description": "RTF subline component with left-aligned text.",
      "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"
        },
        "text": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Text content",
          "title": "Text"
        },
        "text_indent_reference": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": "table",
          "description": "Reference point for indentation ('page' or 'table')",
          "title": "Text Indent Reference"
        }
      },
      "title": "RTFSubline",
      "type": "object"
    },
    "RTFTitle": {
      "description": "RTF title component with center-aligned text and LaTeX conversion enabled.\n\nThe RTFTitle component displays centered title text at the top of the document\nor table. It supports multiple title lines and LaTeX-style text conversion\nfor mathematical symbols and formatting.\n\nExamples:\n    Single line title:\n    ```python\n    title = RTFTitle(text=\"Adverse Events Summary\")\n    ```\n\n    Multi-line title with formatting:\n    ```python\n    title = RTFTitle(\n        text=[\"Clinical Study Report\", \"Safety Analysis Set\"],\n        text_format=[\"b\", \"\"]  # First line bold, second normal\n    )\n    ```\n\n    Title with LaTeX symbols:\n    ```python\n    title = RTFTitle(\n        text=\"Efficacy Analysis (\\\\alpha = 0.05)\"\n    )\n    # Renders as: Efficacy Analysis (alpha = 0.05) with Greek alpha symbol\n    ```\n\nNote:\n    Text conversion is enabled by default for titles, converting:\n    - LaTeX symbols (e.g., \\\\alpha to Greek alpha, \\\\beta to Greek beta)\n    - Subscripts (e.g., x_1 to x with subscript 1)\n    - Other mathematical notation",
      "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"
        },
        "text": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Text content",
          "title": "Text"
        },
        "text_indent_reference": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": "table",
          "description": "Reference point for indentation ('page' or 'table')",
          "title": "Text Indent Reference"
        }
      },
      "title": "RTFTitle",
      "type": "object"
    }
  },
  "description": "Main class for creating RTF documents with tables, text, and figures.\n\nRTFDocument is the central class for generating Rich Text Format (RTF) files\ncontaining formatted tables, titles, footnotes, and other document elements.\nIt provides a comprehensive API for creating professional documents commonly\nused in clinical trials, scientific research, and data reporting.\n\nExamples:\n    Simple table with title:\n    ```python\n    import rtflite as rtf\n    import polars as pl\n\n    df = pl.DataFrame({\n        \"Subject\": [\"001\", \"002\", \"003\"],\n        \"Age\": [45, 52, 38],\n        \"Treatment\": [\"Drug A\", \"Drug B\", \"Placebo\"]\n    })\n\n    doc = rtf.RTFDocument(\n        df=df,\n        rtf_title=rtf.RTFTitle(text=\"Patient Demographics\"),\n        rtf_body=rtf.RTFBody(col_rel_width=[2, 1, 2])\n    )\n    doc.write_rtf(\"demographics.rtf\")\n    ```\n\n    Multi-page document with headers and footers:\n    ```python\n    doc = rtf.RTFDocument(\n        df=large_df,\n        rtf_page=rtf.RTFPage(nrow=40, orientation=\"landscape\"),\n        rtf_page_header=rtf.RTFPageHeader(),  # Default page numbering\n        rtf_page_footer=rtf.RTFPageFooter(text=\"Confidential\"),\n        rtf_title=rtf.RTFTitle(text=\"Clinical Study Results\"),\n        rtf_column_header=rtf.RTFColumnHeader(\n            text=[\"Subject ID\", \"Visit\", \"Result\", \"Units\"]\n        ),\n        rtf_body=rtf.RTFBody(\n            col_rel_width=[2, 1, 1, 1],\n            text_justification=[[\"l\", \"c\", \"r\", \"c\"]]\n        ),\n        rtf_footnote=rtf.RTFFootnote(\n            text=\"Results are mean +/- SD\"\n        )\n    )\n    doc.write_rtf(\"results.rtf\")\n    ```\n\n    Document with grouped data and sublines:\n    ```python\n    doc = rtf.RTFDocument(\n        df=grouped_df,\n        rtf_body=rtf.RTFBody(\n            group_by=[\"SITE\", \"TREATMENT\"],  # Suppress duplicate values\n            subline_by=[\"STUDY_PHASE\"],      # Create section headers\n            col_rel_width=[2, 2, 1, 1]\n        )\n    )\n    ```\n\nAttributes:\n    df: Data to display in the table. Can be a single DataFrame or list of\n        DataFrames for multi-section documents. Accepts pandas or polars\n        DataFrames (automatically converted to polars internally).\n\n    rtf_page: Page configuration including size, orientation, margins, and\n        pagination settings.\n\n    rtf_page_header: Optional header appearing at the top of every page.\n\n    rtf_page_footer: Optional footer appearing at the bottom of every page.\n\n    rtf_title: Document title(s) displayed at the top.\n\n    rtf_column_header: Column headers for the table. Can be a single header\n        or list of headers for multi-row headers.\n\n    rtf_body: Table body configuration including column widths, formatting,\n        borders, and special features like group_by and subline_by.\n\n    rtf_footnote: Optional footnote text displayed after the table.\n\n    rtf_source: Optional source citation displayed at the very bottom.\n\n    rtf_figure: Optional figure/image to embed in the document.\n\nMethods:\n    rtf_encode(): Generate the complete RTF document as a string.\n    write_rtf(file_path): Write the RTF document to a file.",
  "properties": {
    "df": {
      "default": null,
      "description": "The DataFrame(s) containing the data for the RTF document. Accepts single DataFrame or list of DataFrames for multi-section documents. Accepts pandas or polars DataFrame, internally converted to polars. Optional when using figure-only documents.",
      "title": "Df",
      "type": "null"
    },
    "rtf_page": {
      "$ref": "#/$defs/RTFPage",
      "description": "Page settings including size, orientation and margins"
    },
    "rtf_page_header": {
      "anyOf": [
        {
          "$ref": "#/$defs/RTFPageHeader"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Text to appear in the header of each page"
    },
    "rtf_title": {
      "anyOf": [
        {
          "$ref": "#/$defs/RTFTitle"
        },
        {
          "type": "null"
        }
      ],
      "description": "Title section settings including text and formatting"
    },
    "rtf_subline": {
      "anyOf": [
        {
          "$ref": "#/$defs/RTFSubline"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Subject line text to appear below the title"
    },
    "rtf_column_header": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/RTFColumnHeader"
          },
          "type": "array"
        },
        {
          "items": {
            "items": {
              "anyOf": [
                {
                  "$ref": "#/$defs/RTFColumnHeader"
                },
                {
                  "type": "null"
                }
              ]
            },
            "type": "array"
          },
          "type": "array"
        }
      ],
      "description": "Column header settings. For multi-section documents, use nested list format: [[header1], [header2], [None]] where None means no header for that section.",
      "title": "Rtf Column Header"
    },
    "rtf_body": {
      "anyOf": [
        {
          "$ref": "#/$defs/RTFBody"
        },
        {
          "items": {
            "$ref": "#/$defs/RTFBody"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "description": "Table body section settings including column widths and formatting. For multi-section documents, provide a list of RTFBody objects.",
      "title": "Rtf Body"
    },
    "rtf_footnote": {
      "anyOf": [
        {
          "$ref": "#/$defs/RTFFootnote"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Footnote text to appear at bottom of document"
    },
    "rtf_source": {
      "anyOf": [
        {
          "$ref": "#/$defs/RTFSource"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Data source citation text"
    },
    "rtf_page_footer": {
      "anyOf": [
        {
          "$ref": "#/$defs/RTFPageFooter"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Text to appear in the footer of each page"
    },
    "rtf_figure": {
      "anyOf": [
        {
          "$ref": "#/$defs/RTFFigure"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Figure/image content to embed in the document"
    }
  },
  "title": "RTFDocument",
  "type": "object"
}

Config:

  • arbitrary_types_allowed: True

Fields:

Validators:

df pydantic-field

df: DataFrame | list[DataFrame] | None = None

The DataFrame(s) containing the data for the RTF document. Accepts single DataFrame or list of DataFrames for multi-section documents. Accepts pandas or polars DataFrame, internally converted to polars. Optional when using figure-only documents.

rtf_page pydantic-field

rtf_page: RTFPage

Page settings including size, orientation and margins

rtf_page_header pydantic-field

rtf_page_header: RTFPageHeader | None = None

Text to appear in the header of each page

rtf_title pydantic-field

rtf_title: RTFTitle | None

Title section settings including text and formatting

rtf_subline pydantic-field

rtf_subline: RTFSubline | None = None

Subject line text to appear below the title

rtf_column_header pydantic-field

rtf_column_header: Sequence[RTFColumnHeader] | Sequence[Sequence[RTFColumnHeader | None]]

Column header settings. For multi-section documents, use nested list format: [[header1], [header2], [None]] where None means no header for that section.

rtf_body pydantic-field

rtf_body: RTFBody | Sequence[RTFBody] | None

Table body section settings including column widths and formatting. For multi-section documents, provide a list of RTFBody objects.

rtf_footnote pydantic-field

rtf_footnote: RTFFootnote | None = None

Footnote text to appear at bottom of document

rtf_source pydantic-field

rtf_source: RTFSource | None = None

Data source citation text

rtf_page_footer: RTFPageFooter | None = None

Text to appear in the footer of each page

rtf_figure pydantic-field

rtf_figure: RTFFigure | None = None

Figure/image content to embed in the document

convert_column_header_to_list pydantic-validator

convert_column_header_to_list(v)

Convert single RTFColumnHeader to list or handle nested list format

validate_dataframe pydantic-validator

validate_dataframe(values)

Convert DataFrame(s) to polars for internal processing.

validate_column_names pydantic-validator

validate_column_names()

Validate column references and multi-section consistency.

rtf_encode

rtf_encode() -> str

Generate the complete RTF document as a string.

This method processes all document components and generates the final RTF code including headers, formatting, tables, and all other elements. The resulting string can be written to a file or processed further.

Returns:

Name Type Description
str str

Complete RTF document string ready to be saved as an .rtf file.

Examples:

doc = RTFDocument(df=data, rtf_title=RTFTitle(text="Report"))
rtf_string = doc.rtf_encode()
# Can write manually or process further
with open("output.rtf", "w") as f:
    f.write(rtf_string)

write_rtf

write_rtf(file_path: str | Path) -> None

Write the RTF document to a file.

Generates the complete RTF document and writes it to the specified file path. The file is written in UTF-8 encoding and will have the .rtf extension.

Parameters:

Name Type Description Default
file_path str | Path

Path where the RTF file should be saved. Accepts string or Path input. Can be absolute or relative. Directories are created if they do not already exist.

required

Examples:

doc = RTFDocument(df=data, rtf_title=RTFTitle(text="Report"))
doc.write_rtf("output/report.rtf")
Note

The method prints the file path to stdout for confirmation.

write_docx

write_docx(file_path: str | Path, *, converter: LibreOfficeConverter | None = None) -> None

Write the document as a DOCX file.

Writes the document to a temporary RTF file first, and then converts it to DOCX with LibreOffice. Temporary directories are used for all intermediate files to avoid placing artifacts alongside the requested output path.

Parameters:

Name Type Description Default
file_path str | Path

Destination path for the DOCX file. Accepts string or Path input. Can be absolute or relative. Directories are created if they do not already exist.

required
converter LibreOfficeConverter | None

Optional LibreOffice converter instance. Pass a configured instance (for example with a custom executable_path) to control how LibreOffice is invoked and to avoid re-initializing and re-verifying the executable path across multiple conversions. Note that each call to convert() still starts a new LibreOffice process in headless mode; the process is not kept alive between conversions.

None

Examples:

doc = RTFDocument(df=data, rtf_title=RTFTitle(text="Report"))
doc.write_docx("output/report.docx")

Custom LibreOffice executable:

converter = LibreOfficeConverter(executable_path="/custom/path/to/soffice")
doc.write_docx("output/report.docx", converter=converter)

Note

The method prints the file path to stdout for confirmation.

write_html

write_html(file_path: str | Path, *, converter: LibreOfficeConverter | None = None) -> None

Write the document as an HTML file.

Writes the document to a temporary RTF file first, and then converts it to HTML with LibreOffice. Temporary directories are used for all intermediate files to avoid placing artifacts alongside the requested output path.

Parameters:

Name Type Description Default
file_path str | Path

Destination path for the HTML file. Accepts string or Path input. Can be absolute or relative. Directories are created if they do not already exist.

required
converter LibreOfficeConverter | None

Optional LibreOffice converter instance. Pass a configured instance (for example with a custom executable_path) to control how LibreOffice is invoked and to avoid re-initializing and re-verifying the executable path across multiple conversions. Note that each call to convert() still starts a new LibreOffice process in headless mode; the process is not kept alive between conversions.

None

Examples:

doc = RTFDocument(df=data, rtf_title=RTFTitle(text="Report"))
doc.write_html("output/report.html")
Note

LibreOffice may create a companion directory (for example report.html_files) for embedded resources. When present, it is moved alongside the requested output path.

write_pdf

write_pdf(file_path: str | Path, *, converter: LibreOfficeConverter | None = None) -> None

Write the document as a PDF file.

Writes the document to a temporary RTF file first, and then converts it to PDF with LibreOffice. Temporary directories are used for all intermediate files to avoid placing artifacts alongside the requested output path.

Parameters:

Name Type Description Default
file_path str | Path

Destination path for the PDF file. Accepts string or Path input. Can be absolute or relative. Directories are created if they do not already exist.

required
converter LibreOfficeConverter | None

Optional LibreOffice converter instance. Pass a configured instance (for example with a custom executable_path) to control how LibreOffice is invoked and to avoid re-initializing and re-verifying the executable path across multiple conversions. Note that each call to convert() still starts a new LibreOffice process in headless mode; the process is not kept alive between conversions.

None

Examples:

doc = RTFDocument(df=data, rtf_title=RTFTitle(text="Report"))
doc.write_pdf("output/report.pdf")

RTFEncodingEngine

RTFEncodingEngine()

Main engine for RTF document encoding.

This class orchestrates the encoding process using the UnifiedRTFEncoder which implements the strategy pattern for pagination and rendering.

encode_document

encode_document(document: RTFDocument) -> str

Encode an RTF document using the unified encoder.

Parameters:

Name Type Description Default
document RTFDocument

The RTF document to encode

required

Returns:

Type Description
str

Complete RTF string

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:

Validators:

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

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

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 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:

Validators:

  • convert_text_beforetext
  • convert_text_aftertext

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

text pydantic-field

text: Sequence[str] | None = None

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

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 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:

Validators:

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.

RTFFootnote pydantic-model

RTFFootnote(**data)

Bases: RTFTableTextComponent

RTF footnote component for explanatory notes and citations.

The RTFFootnote component displays footnote text at the bottom of tables. Supports multiple footnote lines and can be rendered as a table (with borders) or plain text. Text conversion is enabled by default.

Examples:

Single footnote:

footnote = RTFFootnote(
    text="CI = Confidence Interval; N = Number of subjects"
)

Multiple footnotes:

footnote = RTFFootnote(
    text=[
        "* p-value from ANCOVA model",
        "** Missing values were imputed using LOCF",
        "*** Baseline is defined as last value before first dose"
    ]
)

Footnote without table borders:

footnote = RTFFootnote(
    text="Data cutoff date: 2023-12-31",
    as_table=False  # No borders around footnote
)

Note
  • Multiple footnote lines are joined with \line separator
  • Text conversion is enabled by default (LaTeX symbols supported)
  • Default rendering includes table borders (as_table=True)
Show JSON schema:
{
  "description": "RTF footnote component for explanatory notes and citations.\n\nThe RTFFootnote component displays footnote text at the bottom of tables.\nSupports multiple footnote lines and can be rendered as a table (with borders)\nor plain text. Text conversion is enabled by default.\n\nExamples:\n    Single footnote:\n    ```python\n    footnote = RTFFootnote(\n        text=\"CI = Confidence Interval; N = Number of subjects\"\n    )\n    ```\n\n    Multiple footnotes:\n    ```python\n    footnote = RTFFootnote(\n        text=[\n            \"* p-value from ANCOVA model\",\n            \"** Missing values were imputed using LOCF\",\n            \"*** Baseline is defined as last value before first dose\"\n        ]\n    )\n    ```\n\n    Footnote without table borders:\n    ```python\n    footnote = RTFFootnote(\n        text=\"Data cutoff date: 2023-12-31\",\n        as_table=False  # No borders around footnote\n    )\n    ```\n\nNote:\n    - Multiple footnote lines are joined with \\\\line separator\n    - Text conversion is enabled by default (LaTeX symbols supported)\n    - Default rendering includes table borders (as_table=True)",
  "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": "Text content",
      "title": "Text"
    },
    "as_table": {
      "description": "Whether to render as table (True) or plain text (False)",
      "title": "As Table",
      "type": "boolean"
    }
  },
  "required": [
    "as_table"
  ],
  "title": "RTFFootnote",
  "type": "object"
}

Fields:

Validators:

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

text pydantic-field

text: Sequence[str] | None = None

Text content

as_table pydantic-field

as_table: bool

Whether to render as table (True) or plain text (False)

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.

RTFPage pydantic-model

RTFPage(**data)

Bases: BaseModel

Configure RTF page layout and pagination settings.

The RTFPage component controls page dimensions, margins, orientation, and pagination behavior including rows per page and border styles for first/last rows across page boundaries.

Examples:

Basic portrait page with custom margins:

page = RTFPage(
    orientation="portrait",
    margin=[
        1.0,
        1.0,
        1.5,
        1.0,
        1.5,
        1.0,
    ],  # left, right, top, bottom, header, footer
)

Landscape layout for wide tables:

page = RTFPage(
    orientation="landscape",
    nrow=30,  # Fewer rows due to landscape
    border_first="double",  # Double border on first row
    border_last="single"    # Single border on last row
)

Attributes:

Name Type Description
nrow int | None

Total number of rows per page including ALL components: - Column headers (if displayed) - Data rows - Footnotes (if present) - Source lines (if present) This is NOT just data rows - it's the complete row budget.

border_first str | None

Border style for the first row of the table. Defaults to "double" for emphasis.

border_last str | None

Border style for the last row of the table. Defaults to "double" for closure.

Note

The nrow parameter represents the total row capacity of a page, not just data rows. Plan accordingly when setting this value.

Show JSON schema:
{
  "description": "Configure RTF page layout and pagination settings.\n\nThe RTFPage component controls page dimensions, margins, orientation,\nand pagination behavior including rows per page and border styles for\nfirst/last rows across page boundaries.\n\nExamples:\n    Basic portrait page with custom margins:\n    ```python\n    page = RTFPage(\n        orientation=\"portrait\",\n        margin=[\n            1.0,\n            1.0,\n            1.5,\n            1.0,\n            1.5,\n            1.0,\n        ],  # left, right, top, bottom, header, footer\n    )\n    ```\n\n    Landscape layout for wide tables:\n    ```python\n    page = RTFPage(\n        orientation=\"landscape\",\n        nrow=30,  # Fewer rows due to landscape\n        border_first=\"double\",  # Double border on first row\n        border_last=\"single\"    # Single border on last row\n    )\n    ```\n\nAttributes:\n    nrow: Total number of rows per page including ALL components:\n        - Column headers (if displayed)\n        - Data rows\n        - Footnotes (if present)\n        - Source lines (if present)\n        This is NOT just data rows - it's the complete row budget.\n\n    border_first: Border style for the first row of the table.\n        Defaults to \"double\" for emphasis.\n\n    border_last: Border style for the last row of the table.\n        Defaults to \"double\" for closure.\n\nNote:\n    The `nrow` parameter represents the total row capacity of a page,\n    not just data rows. Plan accordingly when setting this value.",
  "properties": {
    "orientation": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": "portrait",
      "description": "Page orientation ('portrait' or 'landscape')",
      "title": "Orientation"
    },
    "width": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Page width in inches",
      "title": "Width"
    },
    "height": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Page height in inches",
      "title": "Height"
    },
    "margin": {
      "anyOf": [
        {
          "items": {
            "type": "number"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Page margins [left, right, top, bottom, header, footer] in inches",
      "title": "Margin"
    },
    "nrow": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Total rows per page including headers, data, footnotes, and sources. NOT just data rows - this is the complete page row budget.",
      "title": "Nrow"
    },
    "border_first": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": "double",
      "description": "First row border style",
      "title": "Border First"
    },
    "border_last": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": "double",
      "description": "Last row border style",
      "title": "Border Last"
    },
    "col_width": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Total width of table columns in inches",
      "title": "Col Width"
    },
    "use_color": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": false,
      "description": "Whether to use color in the document",
      "title": "Use Color"
    },
    "page_title": {
      "default": "all",
      "description": "Where to display titles in multi-page documents ('first', 'last', 'all')",
      "title": "Page Title",
      "type": "string"
    },
    "page_footnote": {
      "default": "last",
      "description": "Where to display footnotes in multi-page documents ('first', 'last', 'all')",
      "title": "Page Footnote",
      "type": "string"
    },
    "page_source": {
      "default": "last",
      "description": "Where to display source in multi-page documents ('first', 'last', 'all')",
      "title": "Page Source",
      "type": "string"
    }
  },
  "title": "RTFPage",
  "type": "object"
}

Fields:

Validators:

orientation pydantic-field

orientation: str | None = 'portrait'

Page orientation ('portrait' or 'landscape')

width pydantic-field

width: float | None = None

Page width in inches

height pydantic-field

height: float | None = None

Page height in inches

margin pydantic-field

margin: Sequence[float] | None = None

Page margins [left, right, top, bottom, header, footer] in inches

nrow pydantic-field

nrow: int | None = None

Total rows per page including headers, data, footnotes, and sources. NOT just data rows - this is the complete page row budget.

border_first pydantic-field

border_first: str | None = 'double'

First row border style

border_last pydantic-field

border_last: str | None = 'double'

Last row border style

col_width pydantic-field

col_width: float | None = None

Total width of table columns in inches

use_color pydantic-field

use_color: bool | None = False

Whether to use color in the document

page_title pydantic-field

page_title: str = 'all'

Where to display titles in multi-page documents ('first', 'last', 'all')

page_footnote pydantic-field

page_footnote: str = 'last'

Where to display footnotes in multi-page documents ('first', 'last', 'all')

page_source pydantic-field

page_source: str = 'last'

Where to display source in multi-page documents ('first', 'last', 'all')

RTFPageFooter pydantic-model

RTFPageFooter(**data)

Bases: RTFTextComponent

RTF page footer component for document footers.

The RTFPageFooter appears at the bottom of every page, typically used for confidentiality notices, timestamps, or file paths. Center-aligned by default.

Examples:

Simple footer:

footer = RTFPageFooter(
    text="Company Confidential"
)

Multi-line footer:

footer = RTFPageFooter(
    text=[
        "Proprietary and Confidential",
        "Do Not Distribute"
    ],
    text_font_size=[8, 8]
)

Footer with timestamp:

footer = RTFPageFooter(
    text="Generated: 2024-01-15 14:30:00 | program.py",
    text_justification=["l"],  # Left align
    text_font_size=[8]
)

Note
  • Center-aligned by default
  • Text conversion is disabled by default to preserve special characters
  • Appears on every page of the document
Show JSON schema:
{
  "description": "RTF page footer component for document footers.\n\nThe RTFPageFooter appears at the bottom of every page, typically used for\nconfidentiality notices, timestamps, or file paths. Center-aligned by default.\n\nExamples:\n    Simple footer:\n    ```python\n    footer = RTFPageFooter(\n        text=\"Company Confidential\"\n    )\n    ```\n\n    Multi-line footer:\n    ```python\n    footer = RTFPageFooter(\n        text=[\n            \"Proprietary and Confidential\",\n            \"Do Not Distribute\"\n        ],\n        text_font_size=[8, 8]\n    )\n    ```\n\n    Footer with timestamp:\n    ```python\n    footer = RTFPageFooter(\n        text=\"Generated: 2024-01-15 14:30:00 | program.py\",\n        text_justification=[\"l\"],  # Left align\n        text_font_size=[8]\n    )\n    ```\n\nNote:\n    - Center-aligned by default\n    - Text conversion is disabled by default to preserve special characters\n    - Appears on every page of the document",
  "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"
    },
    "text": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Text content",
      "title": "Text"
    },
    "text_indent_reference": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": "table",
      "description": "Reference point for indentation ('page' or 'table')",
      "title": "Text Indent Reference"
    }
  },
  "title": "RTFPageFooter",
  "type": "object"
}

Fields:

Validators:

  • convert_texttext

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

text pydantic-field

text: Sequence[str] | None = None

Text content

text_indent_reference pydantic-field

text_indent_reference: str | None = 'table'

Reference point for indentation ('page' or 'table')

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)

RTFPageHeader pydantic-model

RTFPageHeader(**data)

Bases: RTFTextComponent

RTF page header component for document headers.

The RTFPageHeader appears at the top of every page, typically used for page numbering, document titles, or study identifiers. Right-aligned by default with automatic page numbering.

Examples:

Default page numbering:

header = RTFPageHeader()  # Shows "Page X of Y"

Custom header text:

header = RTFPageHeader(
    text="Protocol ABC-123 | Confidential",
    text_justification=["c"]  # Center align
)

Header with page number:

header = RTFPageHeader(
    text="Study Report - Page \\chpgn",  # Current page number
    text_format=["b"],  # Bold
    text_font_size=[10]
)

Note
  • Default text is "Page \chpgn of {\field{\*\fldinst NUMPAGES }}"
  • Text conversion is disabled by default to preserve RTF field codes
  • Right-aligned by default
Show JSON schema:
{
  "description": "RTF page header component for document headers.\n\nThe RTFPageHeader appears at the top of every page, typically used for\npage numbering, document titles, or study identifiers. Right-aligned by\ndefault with automatic page numbering.\n\nExamples:\n    Default page numbering:\n    ```python\n    header = RTFPageHeader()  # Shows \"Page X of Y\"\n    ```\n\n    Custom header text:\n    ```python\n    header = RTFPageHeader(\n        text=\"Protocol ABC-123 | Confidential\",\n        text_justification=[\"c\"]  # Center align\n    )\n    ```\n\n    Header with page number:\n    ```python\n    header = RTFPageHeader(\n        text=\"Study Report - Page \\\\chpgn\",  # Current page number\n        text_format=[\"b\"],  # Bold\n        text_font_size=[10]\n    )\n    ```\n\nNote:\n    - Default text is \"Page \\\\chpgn of {\\\\field{\\\\*\\\\fldinst NUMPAGES }}\"\n    - Text conversion is disabled by default to preserve RTF field codes\n    - Right-aligned by default",
  "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"
    },
    "text": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Text content",
      "title": "Text"
    },
    "text_indent_reference": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": "table",
      "description": "Reference point for indentation ('page' or 'table')",
      "title": "Text Indent Reference"
    }
  },
  "title": "RTFPageHeader",
  "type": "object"
}

Fields:

Validators:

  • convert_texttext

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

text pydantic-field

text: Sequence[str] | None = None

Text content

text_indent_reference pydantic-field

text_indent_reference: str | None = 'table'

Reference point for indentation ('page' or 'table')

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)

RTFSource pydantic-model

RTFSource(**data)

Bases: RTFTableTextComponent

RTF source component for data source citations.

The RTFSource component displays source information at the very bottom of the document. Typically used for dataset names, program references, or generation timestamps. Rendered as plain text without borders by default.

Examples:

Simple source citation:

source = RTFSource(
    text="Source: ADAE dataset, generated 2024-01-15"
)

Multiple source lines:

source = RTFSource(
    text=[
        "Dataset: ADAE version 3.0",
        "Program: ae_summary.py",
        "Generated: 2024-01-15 14:30:00"
    ]
)

Source with table borders:

source = RTFSource(
    text="Database lock: 2023-12-31",
    as_table=True,  # Add borders around source
    text_justification=[["l"]]  # Left align instead of center
)

Note
  • Center-aligned by default
  • Rendered without borders by default (as_table=False)
  • Text conversion is enabled by default
Show JSON schema:
{
  "description": "RTF source component for data source citations.\n\nThe RTFSource component displays source information at the very bottom\nof the document. Typically used for dataset names, program references,\nor generation timestamps. Rendered as plain text without borders by default.\n\nExamples:\n    Simple source citation:\n    ```python\n    source = RTFSource(\n        text=\"Source: ADAE dataset, generated 2024-01-15\"\n    )\n    ```\n\n    Multiple source lines:\n    ```python\n    source = RTFSource(\n        text=[\n            \"Dataset: ADAE version 3.0\",\n            \"Program: ae_summary.py\",\n            \"Generated: 2024-01-15 14:30:00\"\n        ]\n    )\n    ```\n\n    Source with table borders:\n    ```python\n    source = RTFSource(\n        text=\"Database lock: 2023-12-31\",\n        as_table=True,  # Add borders around source\n        text_justification=[[\"l\"]]  # Left align instead of center\n    )\n    ```\n\nNote:\n    - Center-aligned by default\n    - Rendered without borders by default (as_table=False)\n    - Text conversion is enabled by default",
  "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": "Text content",
      "title": "Text"
    },
    "as_table": {
      "description": "Whether to render as table (True) or plain text (False)",
      "title": "As Table",
      "type": "boolean"
    }
  },
  "required": [
    "as_table"
  ],
  "title": "RTFSource",
  "type": "object"
}

Fields:

Validators:

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

text pydantic-field

text: Sequence[str] | None = None

Text content

as_table pydantic-field

as_table: bool

Whether to render as table (True) or plain text (False)

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.

RTFSubline pydantic-model

RTFSubline(**data)

Bases: RTFTextComponent

RTF subline component with left-aligned text.

Show JSON schema:
{
  "description": "RTF subline component with left-aligned text.",
  "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"
    },
    "text": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Text content",
      "title": "Text"
    },
    "text_indent_reference": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": "table",
      "description": "Reference point for indentation ('page' or 'table')",
      "title": "Text Indent Reference"
    }
  },
  "title": "RTFSubline",
  "type": "object"
}

Fields:

Validators:

  • convert_texttext

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

text pydantic-field

text: Sequence[str] | None = None

Text content

text_indent_reference pydantic-field

text_indent_reference: str | None = 'table'

Reference point for indentation ('page' or 'table')

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)

RTFTitle pydantic-model

RTFTitle(**data)

Bases: RTFTextComponent

RTF title component with center-aligned text and LaTeX conversion enabled.

The RTFTitle component displays centered title text at the top of the document or table. It supports multiple title lines and LaTeX-style text conversion for mathematical symbols and formatting.

Examples:

Single line title:

title = RTFTitle(text="Adverse Events Summary")

Multi-line title with formatting:

title = RTFTitle(
    text=["Clinical Study Report", "Safety Analysis Set"],
    text_format=["b", ""]  # First line bold, second normal
)

Title with LaTeX symbols:

title = RTFTitle(
    text="Efficacy Analysis (\\alpha = 0.05)"
)
# Renders as: Efficacy Analysis (alpha = 0.05) with Greek alpha symbol

Note

Text conversion is enabled by default for titles, converting: - LaTeX symbols (e.g., \alpha to Greek alpha, \beta to Greek beta) - Subscripts (e.g., x_1 to x with subscript 1) - Other mathematical notation

Show JSON schema:
{
  "description": "RTF title component with center-aligned text and LaTeX conversion enabled.\n\nThe RTFTitle component displays centered title text at the top of the document\nor table. It supports multiple title lines and LaTeX-style text conversion\nfor mathematical symbols and formatting.\n\nExamples:\n    Single line title:\n    ```python\n    title = RTFTitle(text=\"Adverse Events Summary\")\n    ```\n\n    Multi-line title with formatting:\n    ```python\n    title = RTFTitle(\n        text=[\"Clinical Study Report\", \"Safety Analysis Set\"],\n        text_format=[\"b\", \"\"]  # First line bold, second normal\n    )\n    ```\n\n    Title with LaTeX symbols:\n    ```python\n    title = RTFTitle(\n        text=\"Efficacy Analysis (\\\\alpha = 0.05)\"\n    )\n    # Renders as: Efficacy Analysis (alpha = 0.05) with Greek alpha symbol\n    ```\n\nNote:\n    Text conversion is enabled by default for titles, converting:\n    - LaTeX symbols (e.g., \\\\alpha to Greek alpha, \\\\beta to Greek beta)\n    - Subscripts (e.g., x_1 to x with subscript 1)\n    - Other mathematical notation",
  "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"
    },
    "text": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Text content",
      "title": "Text"
    },
    "text_indent_reference": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": "table",
      "description": "Reference point for indentation ('page' or 'table')",
      "title": "Text Indent Reference"
    }
  },
  "title": "RTFTitle",
  "type": "object"
}

Fields:

Validators:

  • convert_texttext

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

text pydantic-field

text: Sequence[str] | None = None

Text content

text_indent_reference pydantic-field

text_indent_reference: str | None = 'table'

Reference point for indentation ('page' or 'table')

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)

PageBreakCalculator pydantic-model

Bases: BaseModel

Calculates where page breaks should occur based on content and constraints

Show JSON schema:
{
  "$defs": {
    "RTFPagination": {
      "description": "Core pagination logic and calculations for RTF documents",
      "properties": {
        "page_width": {
          "description": "Page width in inches",
          "title": "Page Width",
          "type": "number"
        },
        "page_height": {
          "description": "Page height in inches",
          "title": "Page Height",
          "type": "number"
        },
        "margin": {
          "description": "Page margins [left, right, top, bottom, header, footer]",
          "items": {
            "type": "number"
          },
          "title": "Margin",
          "type": "array"
        },
        "nrow": {
          "description": "Maximum rows per page",
          "title": "Nrow",
          "type": "integer"
        },
        "orientation": {
          "description": "Page orientation",
          "title": "Orientation",
          "type": "string"
        }
      },
      "required": [
        "page_width",
        "page_height",
        "margin",
        "nrow",
        "orientation"
      ],
      "title": "RTFPagination",
      "type": "object"
    }
  },
  "description": "Calculates where page breaks should occur based on content and constraints",
  "properties": {
    "pagination": {
      "$ref": "#/$defs/RTFPagination",
      "description": "Pagination configuration"
    }
  },
  "required": [
    "pagination"
  ],
  "title": "PageBreakCalculator",
  "type": "object"
}

Config:

  • arbitrary_types_allowed: True

Fields:

pagination pydantic-field

pagination: RTFPagination

Pagination configuration

calculate_content_rows

calculate_content_rows(df: DataFrame, col_widths: Sequence[float], table_attrs: TableAttributes | None = None, font_size: float = 9, spanning_columns: Sequence[str] | None = None) -> Sequence[int]

Calculate how many rows each content row will occupy when rendered

Parameters:

Name Type Description Default
df DataFrame

DataFrame containing the content

required
col_widths Sequence[float]

Width of each column in inches

required
table_attrs TableAttributes | None

Table attributes containing cell height and font size info

None
font_size float

Default font size in points

9
spanning_columns Sequence[str] | None

Columns that should be treated as spanning the full width

None

Returns:

Type Description
Sequence[int]

List of row counts for each data row

find_page_breaks

find_page_breaks(df: DataFrame, col_widths: Sequence[float], page_by: Sequence[str] | None = None, new_page: bool = False, table_attrs: TableAttributes | None = None, additional_rows_per_page: int = 0) -> Sequence[tuple[int, int]]

Find optimal page break positions (r2rtf compatible)

Parameters:

Name Type Description Default
df DataFrame

DataFrame to paginate

required
col_widths Sequence[float]

Column widths in inches

required
page_by Sequence[str] | None

Columns to group by for page breaks

None
new_page bool

Whether to force new pages between groups

False
table_attrs TableAttributes | None

Table attributes for accurate row calculation

None
additional_rows_per_page int

Additional rows per page (headers, footnotes, sources)

0

Returns:

Type Description
Sequence[tuple[int, int]]

List of (start_row, end_row) tuples for each page

calculate_row_metadata

calculate_row_metadata(df: DataFrame, col_widths: Sequence[float], page_by: Sequence[str] | None = None, subline_by: Sequence[str] | None = None, table_attrs: TableAttributes | None = None, removed_column_indices: Sequence[int] | None = None, font_size: float = 9, additional_rows_per_page: int = 0, new_page: bool = False) -> DataFrame

Generate complete row metadata for pagination.

RTFPagination pydantic-model

Bases: BaseModel

Core pagination logic and calculations for RTF documents

Show JSON schema:
{
  "description": "Core pagination logic and calculations for RTF documents",
  "properties": {
    "page_width": {
      "description": "Page width in inches",
      "title": "Page Width",
      "type": "number"
    },
    "page_height": {
      "description": "Page height in inches",
      "title": "Page Height",
      "type": "number"
    },
    "margin": {
      "description": "Page margins [left, right, top, bottom, header, footer]",
      "items": {
        "type": "number"
      },
      "title": "Margin",
      "type": "array"
    },
    "nrow": {
      "description": "Maximum rows per page",
      "title": "Nrow",
      "type": "integer"
    },
    "orientation": {
      "description": "Page orientation",
      "title": "Orientation",
      "type": "string"
    }
  },
  "required": [
    "page_width",
    "page_height",
    "margin",
    "nrow",
    "orientation"
  ],
  "title": "RTFPagination",
  "type": "object"
}

Config:

  • arbitrary_types_allowed: True

Fields:

page_width pydantic-field

page_width: float

Page width in inches

page_height pydantic-field

page_height: float

Page height in inches

margin pydantic-field

margin: Sequence[float]

Page margins [left, right, top, bottom, header, footer]

nrow pydantic-field

nrow: int

Maximum rows per page

orientation pydantic-field

orientation: str

Page orientation

calculate_available_space

calculate_available_space() -> Mapping[str, float]

Calculate available space for content on each page

assemble_docx

assemble_docx(input_files: list[str], output_file: str, landscape: bool | list[bool] = False) -> None

Combine multiple RTF files into a single DOCX file.

Parameters:

Name Type Description Default
input_files list[str]

List of paths to input RTF files.

required
output_file str

Path to the output DOCX file.

required
landscape bool | list[bool]

Whether the output should be landscape. Can be a single bool (applies to all) or a list of bools (one per file). Defaults to False.

False

assemble_rtf

assemble_rtf(input_files: list[str], output_file: str) -> None

Combine multiple RTF files into a single RTF file.

Parameters:

Name Type Description Default
input_files list[str]

List of paths to RTF files to combine.

required
output_file str

Path to the output RTF file.

required

concatenate_docx

concatenate_docx(input_files: Sequence[str | PathLike[str]], output_file: str | PathLike[str], landscape: bool | Sequence[bool] = False) -> None

Concatenate DOCX files without relying on Word field toggles.

This helper is useful when RTFDocument.write_docx already produced DOCX files and you need to stitch them together into a single document that can be distributed without refreshing fields in Microsoft Word.

Parameters:

Name Type Description Default
input_files Sequence[str | PathLike[str]]

Ordered collection of DOCX file paths to combine. The first document becomes the base; subsequent documents are appended as new sections.

required
output_file str | PathLike[str]

Path to the combined DOCX file.

required
landscape bool | Sequence[bool]

Whether each appended section should be landscape. Accepts a single boolean applied to every section or a list/tuple matching input_files.

False

Raises:

Type Description
ImportError

If python-docx is not installed.

ValueError

If input_files is empty or the landscape list length does not match input_files.

FileNotFoundError

If any input file is missing.

get_string_width

get_string_width(text: str, font: FontName | FontNumber = 'Times New Roman', font_size: float = 12, unit: Unit = 'in', dpi: float = 72.0) -> float

Calculate the width of a string for a given font and size. Uses metric-compatible fonts that match the metrics of common proprietary fonts.

Parameters:

Name Type Description Default
text str

The string to measure.

required
font FontName | FontNumber

RTF font name or RTF font number (1-10).

'Times New Roman'
font_size float

Font size in points.

12
unit Unit

Unit to return the width in.

'in'
dpi float

Dots per inch for unit conversion.

72.0

Returns:

Type Description
float

Width of the string in the specified unit.

Raises:

Type Description
ValueError

If an unsupported font name/number or unit is provided.