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

How to use template in footnotes #379

Open
huahmj opened this issue Aug 26, 2021 · 4 comments · May be fixed by #563
Open

How to use template in footnotes #379

huahmj opened this issue Aug 26, 2021 · 4 comments · May be fixed by #563

Comments

@huahmj
Copy link

huahmj commented Aug 26, 2021

Describe your problem

I want to use template in footnotes, but it not work

More details about your problem

There are footnotes in my DOCX document, and I need to replace the text in the footnotes with templates. I added a footnote like {{var}}, but the final render docX does not replace var correctly, just shows {{var}} in the footnote

Provide a test case

Screenshots

@elapouya
Copy link
Owner

Please provide a fully runnable example

@staffanm
Copy link
Contributor

staffanm commented Oct 4, 2021

I have the same problem. This is my code:

from docxtpl import DocxTemplate
doc = DocxTemplate("footnote.docx")
context = { 'what' : "Apples" }
doc.render(context)
doc.save("out.docx")

The result is a word document where {{what}} has been substituted in the main body text. but not in the footnote.

The footnote.docx template I'm using is available at https://github.com/staffanm/staffanm.github.io/raw/master/footnote.docx

Edit: Looking deeper into this, it seems that the underlying python-docx package does not support reading or writing footnotes at all yet (python-openxml/python-docx#1). To support this, the dependency on python-docx may need to be changed to the https://github.com/BayooG/bayoo-docx fork of that library.

@elapouya
Copy link
Owner

elapouya commented Oct 5, 2021

I confirm, footnotes are not supported : adding request for enhancement label...

One precision : footnotes are not the same as footers which are supported.

@bartbroere bartbroere linked a pull request Sep 17, 2024 that will close this issue
@jayvynl
Copy link

jayvynl commented Nov 6, 2024

I've encountered a similar issue, but my requirements are more challenging. I need to use footnote and footnote reference in a for loop.

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

Successfully merging a pull request may close this issue.

4 participants