elapouya / python-docx-template

Use a docx as a jinja2 template
GNU Lesser General Public License v2.1
1.92k stars 378 forks source link

Forms and documents are corrupted when using vm tags #522

Open phybrain opened 6 months ago

phybrain commented 6 months ago

Describe the bug

A clear and concise description of what the bug is. my template:
image my result:
image There are only 2 rows, and the rest of the forms and documents have all disappeared

To Reproduce

python 3.6.6, docxtpl==0.16.7,python-docx==0.8.11

elapouya commented 6 months ago

Please, provide a fully runnable test case, not just pictures.

Message ID: @.***>

phybrain commented 6 months ago

Please, provide a fully runnable test case, not just pictures. Message ID: @.***>

from docxtpl import DocxTemplate, InlineImage

tpl = DocxTemplate('./test.docx')

context = {
    'repeat_purchase_list': [{'total': 100, 'name': 'A', 'count': 1}, {'total': 200, 'name': 'B', 'count': 1},
                             {'total': 300, 'name': 'C', 'count': 1}, {'total': 400, 'name': 'D', 'count': 1}
                             ]

}

tpl.render(context)
tpl.save('./out.docx')

test.docx

I upload my test docx template,thankyou.

SergeyZaykov commented 5 months ago

I confirm the bug and I got workaround.

I selected the table and changed the style to Normal (test Normal style.docx). The output document was as excpected.

I found out that changing the font didn't resolve the bug.

phybrain commented 5 months ago

I confirm the bug and I got workaround.

I selected the table and changed the style to Normal (test Normal style.docx). The output document was as excpected.

I found out that changing the font didn't resolve the bug.

Thanks.