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

Issue with DOCX Insertion — Formatting Broken in OnlyOffice/LibreOffice #583

Open
skaffolding-manish opened this issue Feb 4, 2025 · 0 comments

Comments

@skaffolding-manish
Copy link

Issue Description:
I’m encountering an issue when using docxtpl to insert a .docx file into another. Specifically, I’m trying to insert Test2.docx into Test1.docx, and the resulting document (output.docx) appears correctly in Microsoft Word but gets misformatted in OnlyOffice.

What Happens:
The inserted content from Test2.docx is placed incorrectly within the structure of Test1.docx, particularly inside a single <w:r> element, which causes formatting issues in OnlyOffice.
Microsoft Word handles this insertion correctly, likely because it has more lenient error handling for improperly structured XML, but OnlyOffice fails to interpret the content properly.

Expected Behavior:
When inserting a .docx into another using docxtpl, the content should be placed into a new paragraph or block, not nested inside a single run, so that document formatting is preserved across different platforms, including OnlyOffice.

Steps to Reproduce:
Use docxtpl to insert Test2.docx into Test1.docx using a placeholder ({{ somefile.docx }}).
Generate the output (output.docx).
Open the output file in OnlyOffice, and you will see the formatting issues.
Open the same file in Microsoft Word, and it will appear as expected.

Attached Files:
Test1.docx — The main file.
Test2.docx — The file being inserted into Test1.docx.
output.docx — The result after the insertion.

Screenshot in Word:
Image

Screenshot in OnlyOffice:
Image

Possible Solution:
It seems like the inserted content is not being placed in a correct block-level structure, and it is being wrapped inside a run. If possible, can docxtpl be modified to handle insertions in a way that preserves proper structure for all platforms, including OnlyOffice?

Thank you for any guidance or suggestions to resolve this issue!

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

No branches or pull requests

1 participant