Relative Content

Tag Archive for docxpython-docx

Setting image with proper margins due to header using python-docx

My task is to automate the formatting of a document according to the user’s input. I had to add cover and back page images with smaller margins than the rest of the document. I figured out how to add the cover page image with some help from ChatGPT, but I am unable to figure out how to properly add a back page image. The problem I’m facing is when adding a new section(since I need different margins), it inherits the header and footer property from the previous section. To prevent this I used is_linked_to_previous = False for both header and footer. But it didn’t quite work. On examining the XML of the docx produced, I found that the new section still had references for header and footer and even the page margin had tags for header and footer which I guess are taking the extra space.
Following is the XML:

how to automate invoice input using docxptl

so I use docxptl to automate the process of making invoices. but, it does not input to my word file. i already follow the tutorial thoroughly, but it does not change anything. here is my code :