You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SubDocs not rendering in LibreOffice/OpenOffice #537
When creating subdocs with doc.new_subdoc() and opening the resulting docx file with LibreOffice, the subdoc is not visibile.
When opening the SAME .docx file with word, the subdoc content is correctly shown.
The example given in the tests does not work for me. When I merge the docx I have just not visible content in the file.
The content is not visible using LibreOffice/Google Docs/Word, BUT it does actually appear inside the XML data. Which means that it is being written in the doc but probably the wrong way ?
It requires good understanding of docx format to answer your question. Unfortunately I do not have sufficient knowledge about that, sorry
Le mar. 7 mai 2024 à 12:06, ScriptSathi ***@***.***(mailto:Le mar. 7 mai 2024 à 12:06, ScriptSathi <<a href=)> a écrit :
Running into this as well. It renders in Word, but interestingly when exporting from Sharepoint as a PDF it goes missing. Opening and printing to PDF retains it.
OK so for me, I found that I can only see subdocuments when included with a {{p subdoc }}. However when I would insert a subdoc with a table with {{p subdoc }} it would break MS Word. Using {{ subdoc }} would work in word but break everything else. The solution I've found to work is to ensure the last element in the subdoc is a paragraph so {{p subdoc }} works.
This may be brittle but worked for me 🤷♂️:
fromdocx.oxml.text.paragraphimportCT_P# Don't finish run without a paragraph, it corrupts the xmlelements=list(subdoc.element.body)
iflen(elements) >1andnotisinstance(elements[-2], CT_P):
subdoc.add_paragraph()
Reacted by JohanBekker, Saitamanistan, Aivaras Aukselis (C1Connections), real-codemeteor, Alex and Amaury Le Roux Dupeyron
@Daniel-Sennewald@pemontto fyi, in Docform (the maintained fork at https://github.com/cvas22/docform, docform on PyPI) a subdoc that ends with a table now gets a paragraph after it, so {{p subdoc }} works there without the workaround (cvas22/docform#188). For LibreOffice the subdoc needs {{p subdoc }} rather than {{ subdoc }}, which the docs now say. It'll be in the next release.
Activity
tdaudi commentedon May 7, 2024
Up
The example given in the tests does not work for me. When I merge the docx I have just not visible content in the file.
The content is not visible using LibreOffice/Google Docs/Word, BUT it does actually appear inside the XML data. Which means that it is being written in the doc but probably the wrong way ?
tdaudi commentedon May 7, 2024
@elapouya sorry for the ping, I have seen you wrote the part of the code related to merging documents.
Do you have any hint to give us for this bug ?
I'm using python
3.12.3and docxtpl version0.17.0Thanks
elapouya commentedon May 8, 2024
pemontto commentedon Sep 22, 2024
Running into this as well. It renders in Word, but interestingly when exporting from Sharepoint as a PDF it goes missing. Opening and printing to PDF retains it.
pemontto commentedon Sep 23, 2024
OK so for me, I found that I can only see subdocuments when included with a
{{p subdoc }}. However when I would insert a subdoc with a table with{{p subdoc }}it would break MS Word. Using{{ subdoc }}would work in word but break everything else. The solution I've found to work is to ensure the last element in the subdoc is a paragraph so{{p subdoc }}works.This may be brittle but worked for me 🤷♂️:
Alkalit commentedon Apr 24, 2025
@pemontto, God bless you, friend.
amaurylrd commentedon Mar 4, 2026
@pemontto merci pour les travaux
cvas22 commentedon Nov 22, 2026
@Daniel-Sennewald @pemontto fyi, in Docform (the maintained fork at https://github.com/cvas22/docform,
docformon PyPI) a subdoc that ends with a table now gets a paragraph after it, so{{p subdoc }}works there without the workaround (cvas22/docform#188). For LibreOffice the subdoc needs{{p subdoc }}rather than{{ subdoc }}, which the docs now say. It'll be in the next release.