Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubDocs not rendering in LibreOffice/OpenOffice #537

Open
Daniel-Sennewald opened this issue Apr 16, 2024 · 3 comments
Open

SubDocs not rendering in LibreOffice/OpenOffice #537

Daniel-Sennewald opened this issue Apr 16, 2024 · 3 comments
Labels

Comments

@Daniel-Sennewald
Copy link

Daniel-Sennewald commented Apr 16, 2024

Describe the bug

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.

To Reproduce

Note: .docx files are attached.

import docxtpl

main_doc_context = {
    "test": "main doc test text",
}

sub_doc_context = {
    "test": "sub doc test text",
}

subdoc = docxtpl.DocxTemplate("./test_libre_sub.docx")
subdoc.render(sub_doc_context)
subdoc.save("./test_libre_sub_rendered.docx")

main_doc = docxtpl.DocxTemplate("./test_libre.docx")
rendered_subdoc = main_doc.new_subdoc("./test_libre_sub_rendered.docx")
main_doc_context["subdoc1"] = rendered_subdoc

main_doc.render(main_doc_context)
main_doc.save("./test_libre_rendered.docx")

test_libre_sub.docx
test_libre.docx

Open the file test_libre_rendered.docx with Word and with LibreOffice. Word renders the subdoc contents, LibreOffice does not.

Expected behavior

When opening the doc with either libreoffice the subdoc should be rendered.

Additional Info

Note that the subdoc itself ("./test_libre_sub_rendered.docx") correctly includes the rendered subdoc.

Tested on:

Mac (Intel) x64
OpenOffice: 4.1.15
LibreOffice: 24.2.2

@ScriptSathi
Copy link

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 ?

@ScriptSathi
Copy link

@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.3 and docxtpl version 0.17.0

Thanks

@elapouya
Copy link
Owner

elapouya commented May 8, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants