PDF ReportΒΆ
- class PDFReport(orientation='L', unit='mm', format='A4', date_format='%B %d %Y', ui_config: dict | None = None)[source]ΒΆ
Bases:
FPDFExtends
FPDFto produce a PDF patch report from a styled DataFrame.The
ui_configdict drives header/footer text, font selection, branding logo, and header color. When omitted,UIDefaultsis used (no plist read, no I/O). The CLI passesUIConfigManager.config(a plist-backed dict); library callers pass a dict they constructed themselves or read from elsewhere.- Parameters:
orientation (str) β Orientation of the PDF, default is βLβ (landscape).
unit (str) β Unit of measurement, default is βmmβ.
format (str) β Page format, default is βA4β.
date_format (str) β Date format string for the PDF report header, default is β%B %d %Yβ.
ui_config (dict | None) β Dict of UI settings (header text, footer, font paths, logo, header color). Defaults to
UIDefaultsvalues.
- static trim_transparency(image_path: str) str[source]ΒΆ
Trims transparent padding from the logo and returns the path to a temporary file.
- header()[source]ΒΆ
Creates the header section for each page of the PDF report with an optional logo.
The header includes the configured header text and the current date formatted according to
self.date_format. On subsequent pages, the table header is also added.
- add_table_header()[source]ΒΆ
Adds the table header to the PDF report.
This method is called on pages after the first to add column headers for the data table in the PDF report. The headers and their widths are defined by
self.table_headersandself.column_widths.
Creates the footer section for each page of the PDF report.
The footer includes the configured footer text and the current page number. The footer text is styled with a smaller font and a light gray color.
- calculate_column_widths(data: DataFrame) list[float][source]ΒΆ
Calculates column widths based on the longer of the header length or the longest content in each column, ensuring they fit within the page width.
- Parameters:
data (pandas.DataFrame) β DataFrame containing dataset to be included in PDF.
- Returns:
A list of column widths proportional to header lengths.
- Return type:
list [
float]