PDFExporter

class qf_lib.documents_utils.document_exporting.pdf_exporter.PDFExporter(settings: qf_lib.settings.Settings)[source]

Bases: qf_lib.documents_utils.document_exporting.document_exporter.DocumentExporter

Stores elements such as the ParagraphElement and ChartElement in order to build a PDF based on them once they have all been added. If there is a “document_css_directory” attribute set in the Settings, then CSS files from that directory will be applied for styling the output page. Otherwise the default styling will be applied.

Methods

generate(documents, export_dir, filename[, …])

Merged all documents into one and then exports the merged document to a PDF file in the given directory.

set_default_directory_level_up()

Sets the document_css_dir one level above ‘default css’, to enable applying css classes in other folders.

generate(documents: List[qf_lib.documents_utils.document_exporting.document.Document], export_dir: str, filename: str, include_table_of_contents=False, css_file_names: List[str] = None) → str[source]

Merged all documents into one and then exports the merged document to a PDF file in the given directory.

Allows defining of multiple css files. The base css file will be applied first, followed sequentially by files defined in css_file_names.

The CSS files must be placed in the Settings.document_css_directory directory. CSS files placed in Settings.document_css_directory/base will be applied for all exported PDF documents.

Parameters
  • documents – list of documents for which files should be generated

  • export_dir – relative path to the directory (relative to the output root directory) in which the PDF should be saved

  • filename – filename under which the merged document should be saved

  • include_table_of_contents – if True then table of contents will be generated at the beginning of the file

  • css_file_names – names of css files which should be applied for generating the PDF

Returns

Return type

the absolute path to the output PDF file that was saved

set_default_directory_level_up()[source]

Sets the document_css_dir one level above ‘default css’, to enable applying css classes in other folders. Using the generate function demands inputting css_file_names as paths from newly set level. e.g: ‘default_cssmain”