Skip to content

RTFDocument

Main entry point for creating complete RTF documents using the unified encoding pipeline. Use this class to combine pages, headers/footers, titles, tables, and figures into production-ready output.

rtflite.encode.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:

  • _table_space (int)
  • df (DataFrame | list[DataFrame] | None)
  • rtf_page (RTFPage)
  • rtf_page_header (RTFPageHeader | None)
  • rtf_title (RTFTitle | None)
  • rtf_subline (RTFSubline | None)
  • rtf_column_header (Sequence[RTFColumnHeader] | Sequence[Sequence[RTFColumnHeader | None]])
  • rtf_body (RTFBody | Sequence[RTFBody] | None)
  • rtf_footnote (RTFFootnote | None)
  • rtf_source (RTFSource | None)
  • rtf_page_footer (RTFPageFooter | None)
  • rtf_figure (RTFFigure | None)

Validators:

  • convert_column_header_to_listrtf_column_header
  • validate_dataframe
  • validate_column_names

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")