2

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).

4

1 回答 1

2

关于第一部分,编辑word模板,你可以看看这个问题:Reading/Writing MS Word files in Python

有一个用于编辑 word 文件的包,称为python-docx

要将word文件转换成pdf文档,应该有多种不同的工具,包括命令行工具。因此,您可以使用 python 编辑文档,然后使用从 python 代码调用的转换器工具来创建 pdf。

于 2013-06-10T12:04:29.403 回答