PDFExporter
- class qf_lib.documents_utils.document_exporting.pdf_exporter.PDFExporter(settings: Settings)[source]
Bases:
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.
Sets the document_css_dir one level above 'default css', to enable applying css classes in other folders.
- generate(documents: List[Document], export_dir: str, filename: str, include_table_of_contents=False, css_file_names: Optional[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
- Return type:
the absolute path to the output PDF file that was saved