Reputation: 7996
I need to generate reports in python. The report needs to contain a header and footer on each page, some text that won't change, some text that's dynamic, and some charts.
I've created a template using Word, and I'm looking for a way of replacing placeholders such as [+my_placeholder+] with text content/charts/whatever.
Is there anything that can let me use Word documents (or something Word can write) as a template to create a PDF in Python? Since I've already created sample reports in Word I want to reuse what I've got instead of having to recreate them using ReportLab or HTML (I know about ReportLab, pyPDF and also xhtml2pdf).
Upvotes: 2
Views: 8429
Reputation: 316
about the first part, editing word templates, you can have a look at this question: Reading/Writing MS Word files in Python
There is a package for editing word files, called python-docx.
For converting word files into pdf documents, there should be a variety of different tools, including command line tools. So you could use python to edit your document and then use a converter tool that you call from your python code to create the pdf.
Upvotes: 2