我需要允许用户编辑和打印与客户相关的文件(发票和其他)。
用户填写打印表单(选择客户端,每月,他/她需要的4种文档中每种文档的拷贝数),然后单击打印按钮。
接下来,我的系统应该做(算法):
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要求:

我的问题是如何生成这个文件(结果)?有https://github.com/mikemaccana/python-docx项目,但不确定它是否可以使用模板(或者至少生成我需要的表).或者我可以将我的所有.docx模板保存为html,并将它们作为普通的django模板使用,但不确定如何将它们合并到一个文档中并创建分页符.或者我应该考虑另一种文字兼容的文件格式?
附注:最好使用python,但它并不重要,我可以使用java/perl/ruby/php/bash/等等。并安装任何与Ubuntu兼容的新软件包.
发布于 2011-10-20 07:33:15
如果使用模板不是绝对必要的,或者如果您愿意用代码重新创建模板,请使用报告室 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
https://stackoverflow.com/questions/7831328
复制相似问题