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
Copied from python-docx-template issue 542, opened by @klalex on 2024-05-04.
I set custom margins for page layout in a template. When I generate docx it changes to default one. What I've noticed is that it depends on content. When I remove some content it works properly. If add content back there is issue described.
@klalex I can't reproduce this on current main, custom page size, orientation and margins survive a render in my tests. Could you attach a template (and the context) where the margins reset? Since it depends on the content, the exact file would help a lot.
@klalex found it, I think. When the paragraph that ends a section also holds a {%p %} tag, the section break got removed with it, so that section picked up the next section's margins. That's why it depended on the content. Fixed in #204, it'll be in the next release, or try pip install git+https://github.com/cvas22/docform. If your template still resets the margins, attach it and I'll reopen.
Activity
cvas22 commentedon Nov 22, 2026
@klalex I can't reproduce this on current main, custom page size, orientation and margins survive a render in my tests. Could you attach a template (and the context) where the margins reset? Since it depends on the content, the exact file would help a lot.
cvas22 commentedon Nov 25, 2026
@klalex found it, I think. When the paragraph that ends a section also holds a
{%p %}tag, the section break got removed with it, so that section picked up the next section's margins. That's why it depended on the content. Fixed in #204, it'll be in the next release, or trypip install git+https://github.com/cvas22/docform. If your template still resets the margins, attach it and I'll reopen.