Table Components¶
Components for creating and formatting tables in RTF documents.
RTFBody¶
Defines the main table body with data and formatting options.
Bases: TableAttributes
Configure table body formatting and layout.
The RTFBody component controls how data is displayed in the RTF table, including column widths, text formatting, borders, and advanced features like group_by for value suppression and subline_by for section headers.
Examples:
Basic table with custom column widths:
Using group_by to suppress duplicate values:
Using subline_by for section headers:
body = RTFBody(
subline_by=["SITE", "STUDY"], # Creates paragraph headers
col_rel_width=[3, 2, 2] # Note: subline_by columns are removed from table
)
Note
When using subline_by: - The specified columns are removed from the table display - Values appear as paragraph headers before each section - Pagination is automatically enabled (new_page=True) - Formatting attributes apply uniformly to the entire table
RTFColumnHeader¶
Creates column headers for tables.
Bases: TableAttributes
Configure column headers for RTF tables.
The RTFColumnHeader component defines column headers that appear at the top of tables and repeat on each page in multi-page documents. Supports multi-row headers and flexible column spanning.
Examples:
Simple column headers:
Headers with custom formatting:
header = RTFColumnHeader(
text=["Subject", "Baseline", "Week 4", "Week 8"],
text_format=["b", "b", "b", "b"], # All bold
text_justification=["l", "c", "c", "c"], # Left, center, center, center
border_bottom=["double", "double", "double", "double"]
)
Multi-row headers with col_rel_width:
# First row spans multiple columns
header1 = RTFColumnHeader(
text=["Patient Info", "Treatment Results"],
col_rel_width=[2, 3] # Spans 2 and 3 columns respectively
)
# Second row with individual columns
header2 = RTFColumnHeader(
text=["ID", "Age", "Drug A", "Drug B", "Placebo"],
col_rel_width=[1, 1, 1, 1, 1]
)
Note
- Headers automatically repeat on each page in multi-page documents
- Use col_rel_width to create spanning headers
- Border styles from RTFPage are applied to the first row
RTFFigure¶
Embeds figures and images in RTF documents.
Bases: BaseModel
RTF Figure component for embedding images in RTF documents.
This class handles figure embedding with support for multiple images, custom sizing, and proper RTF encoding.
Row Components¶
Lower-level components for row construction.