Core utilities
Low-level components for configuring defaults and working with assets.
Configuration & constants
rtflite.core.RTFConfiguration
dataclass
RTFConfiguration(page: PageConfiguration , fonts: FontConfiguration , colors: ColorConfiguration , borders: BorderConfiguration , text: TextConfiguration )
Master configuration container for RTF document generation.
create_default
classmethod
create_default() -> RTFConfiguration
Create default RTF configuration.
create_pharmaceutical_standard
classmethod
create_pharmaceutical_standard() -> RTFConfiguration
Create configuration optimized for pharmaceutical reporting.
create_landscape
classmethod
create_landscape() -> RTFConfiguration
Create landscape-oriented configuration.
rtflite.core.RTFDefaults
Default values for RTF document configuration.
get_default_colors
classmethod
get_default_colors() -> Mapping [str , str ]
Get all colors from the comprehensive color table.
DEFAULT_COLORS
classmethod
DEFAULT_COLORS() -> Mapping [str , str ]
Get all colors from the comprehensive color table (cached).
rtflite.core.RTFConstants
Core RTF constants for measurements, formatting, and control codes.
TWIPS_PER_INCH
class-attribute
instance-attribute
TWIPS_PER_INCH: Final [int ] = 1440
Number of twips in one inch. RTF uses twips as the base unit.
POINTS_PER_INCH
class-attribute
instance-attribute
POINTS_PER_INCH: Final [int ] = 72
Number of points in one inch.
LINE_SPACING_FACTOR
class-attribute
instance-attribute
LINE_SPACING_FACTOR: Final [int ] = 240
Factor used for line spacing calculations in RTF.
DEFAULT_BORDER_WIDTH
class-attribute
instance-attribute
DEFAULT_BORDER_WIDTH: Final [int ] = 15
Default border width in twips.
DEFAULT_CELL_HEIGHT
class-attribute
instance-attribute
DEFAULT_CELL_HEIGHT: Final [float ] = 0.15
Default cell height in inches.
DEFAULT_SPACE_BEFORE
class-attribute
instance-attribute
DEFAULT_SPACE_BEFORE: Final [int ] = 15
Default space before paragraph in points.
DEFAULT_SPACE_AFTER
class-attribute
instance-attribute
DEFAULT_SPACE_AFTER: Final [int ] = 15
Default space after paragraph in points.
DEFAULT_FONT_SIZE
class-attribute
instance-attribute
DEFAULT_FONT_SIZE: Final [float ] = 9
Default font size in points.
Control
RTF control word constants.
Figure utilities
rtflite.figure.rtf_read_figure
rtf_read_figure(file_paths: str | Path | Sequence [str | Path ]) -> tuple [Sequence [bytes ], Sequence [str ]]
Read image files and return their binary data with format information.
This function reads image files from disk and prepares them for embedding in RTF documents. It supports PNG, JPEG, and EMF formats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_paths
|
|
Single file path or list of file paths to image files |
required |
Returns:
| Type | Description |
|---|---|
|
Tuple of (figure_data, figure_formats) where: - figure_data: List of image binary data as bytes - figure_formats: List of format strings ('png', 'jpeg', 'emf') |
Raises:
| Type | Description |
|---|---|
|
If any image file cannot be found |
|
If image format is not supported |