PdfReport

class pdfpug.PdfReport(**kwargs)

This is the main class that assembles the elements together to create the final PDF output. All the PdfPug elements defined in the API Documentation section need to be added to this class.

Parameters:theme (Optional[Theme]) – PDF file theme
>>> from pdfpug.modules import Header
>>> from pdfpug import PdfReport
>>> header = Header('PdfPug Header')
>>> report = PdfReport()
>>> report.add_element(header)
>>> report.generate_pdf('pug-report.pdf')

PdfPug ships with a predefined themes that can be used to further style and modernise the output pdf file.

>>> from pdfpug.common import Theme
>>> report = PdfReport(theme=Theme.mood_swing)
>>> report.generate_pdf('pug-report.pdf')
add_element(element)

Add an element to the PDF file

Parameters:element (BasePugElement) – Object instance of the different modules supported by PdfPug
Raises:TypeError – If object instance is not a PdfPug element
Return type:None
add_elements(elements)

Add multiple elements in one call to the PDF file

Parameters:elements (List[BasePugElement]) – Each element must be an object instance supported by PdfPug
Raises:TypeError – If object instance is not a PdfPug element
Return type:None
set_meta_information(title=None, description=None, authors=None, keywords=None)

Set the document’s meta information such as title, description, author etc.

Parameters:
  • title (Optional[str]) – Document title
  • description (Optional[str]) – Document description
  • authors (Optional[List[~T]]) – Document authors
  • keywords (Optional[List[~T]]) – Document keywords
Return type:

None

generate_pdf(pdf_file_path)

Generate PDF file

Parameters:pdf_file_path (str) – Absolute path of the PDF file to be created
Return type:None