Search code examples
python-2.7docxpython-docx

Python: Is there a way I can add a footnote to word document?


I have tried the following with python-docx:

section = self.document.sections[0]
footer = section._sectPr.footer
footer.text = "I am here"

I couldn't find a clear footer/header directions in docx documentations. Is there a work around to cover this gap?


Solution

  • The work around is:

    • Create a document with python-docx.
    • Change the name to 'init.docx'
    • Comment any adding-new-style code
    • Open 'init.docx'
    • Delete everything
    • Save it.
    • Add footnote/Headers to 'init.docx'
    • Change self.document = Document('') to self.document = Document('init.docx').