PDF Report#

Model inherits from FPDF.

class PDFReport(ui_config: UIConfigManager, orientation='L', unit='mm', format='A4', date_format='%B %d %Y')[source]#

Handles the generation of PDF reports from Excel files.

The PDFReport class extends FPDF to create a PDF report from an Excel file containing patch data. It supports custom headers, footers, and font styles based on the UI configuration.

Initializes the PDFReport with the provided parameters and UIConfigManager.

Parameters:
  • ui_config (UIConfigManager) – An instance of UIConfigManager for managing UI configuration.

  • 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”.

header()[source]#

Creates the header section for each page of the PDF report.

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_headers and self.column_widths.

footer()[source]#

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.

export_excel_to_pdf(excel_file: str | Path, date_format: AnyStr = '%B %d %Y') None[source]#

Creates a PDF report from an Excel file containing patch data.

This method reads an Excel file, extracts the data, and populates it into a PDF report using the defined headers and column widths. The PDF is then saved to the same directory as the Excel file.

Parameters:
  • excel_file (Union[str, Path]) – Path to the Excel file to convert to PDF.

  • date_format (AnyStr) – The date format string for the PDF report header.

Return type:

None