python-docx-template
python-docx-template copied to clipboard
Adding exist doc as subdoc
Hi! I want add exist doc as subdoc, but have some problems. My code:
doc = DocxTemplate("main.docx")
sub_doc = doc.new_subdoc("content.docx")
context = {"content": sub_doc}
doc.render(context)
doc.save("generated_doc.docx")
main.docx contains:
My document.
{{p content }}
End.
content.docx contains:
In result I have:
- The table has no borders.
- The list has more indentation.
- The picture is not displayed.
How can these errors be fixed? And is it possible to add tags to content.docx and render them as in the main document?
Unfortunately, include an existing subdoc into a doc is very partial. subdoc feature is more to create a doc from ground up by using python-docx library.
I want solve picture is not displayed. 1.save picture and use InlineImage; 2.You kan see http://www.cxyzjd.com/article/weixin_38557885/105059455