python-docx-template icon indicating copy to clipboard operation
python-docx-template copied to clipboard

Adding exist doc as subdoc

Open extraspeed opened this issue 4 years ago • 2 comments

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: 1

In result I have: 2

  1. The table has no borders.
  2. The list has more indentation.
  3. 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?

extraspeed avatar Apr 15 '21 22:04 extraspeed

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.

elapouya avatar Jul 16 '21 09:07 elapouya

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

Mustard404 avatar Aug 05 '21 13:08 Mustard404