Reports API¶
Content fills the remaining page space in insertion order. Use add_page_break()
for an explicit boundary. add_text exposes typography and spacing; add_table
and add_chart accept resize="full" (default), width fractions, or "original".
add_table paginates long tables automatically; paginate=False fits one block.
See the report guide for styled text, visual sizing,
automatic pagination, paper settings, and cover-page examples.
tabloom.report
¶
Flow text, tables, and charts into available space on uniform PDF pages.
The public Report class retains supplied visuals for reuse and manages
only its own temporary figures. Import it from tabloom or
tabloom.report. Text styling and visual width policies are configured per
element. Constructor and composition methods are documented below.
Report
Source
¶
Report(title: str | None = None, *, theme: str = 'blue', figsize: tuple[float, float] = (8.27, 11.69), margin: float = 0.6)
Compose text, tables, and charts into an ordered multipage PDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Optional heading on the first page. A title alone is a valid report. |
None
|
theme
|
str
|
Theme for report pages and text. Existing visuals retain their own themes and any matplotlib customizations. |
'blue'
|
figsize
|
tuple[float, float]
|
Common paper width and height in inches. Defaults to A4 portrait. |
(8.27, 11.69)
|
margin
|
float
|
Printable margin in inches; defaults to 0.6 on every side. |
0.6
|
Content flows into the remaining page space in insertion order. Text wraps and paginates; long tables continue with repeated headers and complete rows. Charts remain intact and move to a fresh page when needed. Vector graphics and searchable text are preserved. All pages have the same paper dimensions. Objects are retained by reference; their current state is used when saving. No external LaTeX is required. Text typography is configurable per block. Visuals fill the printable width by default; select fractional width or original sizing on each add method.
add_text
Source
¶
add_text(text: str, *, font_family: str = 'DejaVu Sans', font_size: float = 12, font_weight: str | int = 'normal', font_style: Literal['normal', 'italic', 'oblique'] = 'normal', color: str | None = None, align: Literal['left', 'center', 'right'] = 'left', line_spacing: float = 1.5, space_after: float = 12) -> Report
Append text to the report in insertion order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
A nonempty string. Paragraphs are wrapped and paginated within the configured paper size and margins when saving. |
required |
font_family
|
str
|
An installed matplotlib font family or generic alias. |
'DejaVu Sans'
|
font_size
|
float
|
Positive font size in points; defaults to 12. |
12
|
font_weight
|
str | int
|
Matplotlib font weight such as normal, bold, or 700. |
'normal'
|
font_style
|
Literal['normal', 'italic', 'oblique']
|
Matplotlib font style: normal, italic, or oblique. |
'normal'
|
color
|
str | None
|
Matplotlib color; None uses the report theme's foreground. |
None
|
align
|
Literal['left', 'center', 'right']
|
Horizontal alignment: left, center, or right. |
'left'
|
line_spacing
|
float
|
Line-height multiplier; finite and at least 1. |
1.5
|
space_after
|
float
|
Nonnegative space after this block in points. |
12
|
Returns:
| Type | Description |
|---|---|
Report
|
This report, allowing method chaining. |
Raises:
| Type | Description |
|---|---|
TypeError
|
A text argument or styling option has an invalid type. |
ValueError
|
Text, typography, color, or spacing is invalid, or the requested font family is unavailable. |
add_table
Source
¶
add_table(table: Table, *, resize: Literal['full', 'original'] | float = 'full', paginate: bool = True) -> Report
Append a table to be rendered from its current data when saving.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
Table
|
A Table instance to place in the nearest available space. Long tables continue across pages with repeated column headers. |
required |
resize
|
Literal['full', 'original'] | float
|
Full printable width by default ("full"), a width fraction in (0, 1], or "original" to keep native size where it fits. Paginated tables retain column proportions and avoid enlarging fonts simply to fill a wider page. |
'full'
|
paginate
|
bool
|
Split long tables into complete rows automatically. False fits the complete table as one block. No captions are added. |
True
|
Returns:
| Type | Description |
|---|---|
Report
|
This report, allowing method chaining. |
Raises:
| Type | Description |
|---|---|
TypeError
|
The input, resize, or paginate has an invalid type. |
ValueError
|
The resize policy or width fraction is invalid. |
add_chart
Source
¶
Append a chart without taking ownership of its figure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chart
|
Chart
|
A Chart instance. Its current figure is exported at save time, and the original dimensions and layout are preserved. |
required |
resize
|
Literal['full', 'original'] | float
|
Full printable width by default ("full"), a width fraction in (0, 1], or "original" to keep native size where it fits. Aspect ratio is preserved; page height may limit the width. |
'full'
|
Returns:
| Type | Description |
|---|---|
Report
|
This report, allowing method chaining. |
Raises:
| Type | Description |
|---|---|
TypeError
|
The input is not a Chart or resize has an invalid type. |
ValueError
|
The resize policy or width fraction is invalid. |
add_page_break
Source
¶
Start a new page before the next content element.
Leading, trailing, and consecutive breaks do not create empty pages. To use a separate title page, add a break immediately after constructing the report.
Returns:
| Type | Description |
|---|---|
Report
|
This report, allowing method chaining. |
save
Source
¶
Write ordered content into the available space on uniform PDF pages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Destination PDF filename; its parent directory must exist. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
The extension is not .pdf or the report has no content and no title. |
Tables and charts remain reusable after saving, including when an export fails. Rendered table and text figures are closed after use.