我需要允许用户编辑和打印与客户相关的文档(发票和其他)。
用户填写打印表格(选择客户,月份,他/她需要四种类型的文档中的每种的多少份)并单击以打印按钮。
接下来,我的系统应该做(算法):
result = create new word-friendly file # because user may manually edit it later
for client in form_clients:
snapshot = select row in snapshots table
where client == client and month == form_month
document1 = generate_from_template(snapshot, tpl1.docx)
for 1 to form_how_much_copies_of_1_type_of_document_he_or_she_needs:
result += document1
document2 = generate_from_template(snapshot, tpl2.docx)
for 1 to form_how_much_copies_of_2_type_of_document_he_or_she_needs:
result += document2
document3 = generate_from_template(snapshot, tpl3.docx)
for 1 to form_how_much_copies_of_3_type_of_document_he_or_she_needs:
result += document3
document4 = generate_from_template(snapshot, tpl4.docx)
for 1 to form_how_much_copies_of_4_type_of_document_he_or_she_needs:
result += document4
print result
Run Code Online (Sandbox Code Playgroud)
要求:

我的问题是如何生成此文件(结果)?有https://github.com/mikemaccana/python-docx项目,但不确定它是否可以与模板一起使用(或至少根据需要生成表)...或者我可以将所有.docx模板另存为html并将它们用作普通的django模板,但不确定如何在1个文档中将它们组合在一起并创建分页符...还是我应该看看另一种与单词兼容的文件格式?
ps最好使用python,但它并不重要,我可以使用java / perl / ruby / php / bash / etc ..并安装任何新的Ubuntu兼容软件包...
如果不是绝对需要使用模板,或者如果您愿意用代码重新创建模板,请使用reportlab for python生成PDF,然后打印。
有关如何制作表格的示例,请参见以下示例:http : //www.blog.pythonlibrary.org/2010/09/21/reportlab-tables-creating-tables-in-pdfs-with-python/
还要查看此发票示例:https : //github.com/radzhome/fedex-commercial-invoice
| 归档时间: |
|
| 查看次数: |
6106 次 |
| 最近记录: |