Skip to content

Document generator improvement #7

@SquakR

Description

@SquakR

The current implementation of the document generator which generates a Word or Pdf document depending on the template requires manual unzipping a Word file and extracting a xml document. Generating a Word or Pdf file from a template is a common task that can be useful to many users. Therefore, this feature can be extracted in another independent library with the following API.

document_generator = DocumentGenerator(
    template='document_template.docx',
    name='my_document',
    output_dir='~/documents',
    variables={'variable1': 'value1', 'variable2': 'value2'}
)
word_path1 = document_generator.generate_docx() 
# word_path1 = '/home/user/documents/my_document.docx'
word_path2 = document_generator.generate_docx(
    name='another_document',
    output_dir='~/another_documents/',
    variables={'variable1': 'value1', 'variable2': 'value2'}
)
# word_path2 = '/home/user/documents/another_document.docx'
pdf_path = document_generator.generate_pdf()
# pdf_path = '/home/user/documents/my_document.pdf'

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions