Skip to content

Conversation

@tiberlas
Copy link

Hi,
I've created footnote support. To the API I added functions:

  • Can read footnotes from a paragraph as a list. The footnote object contains footnote reference id and paragraphs.
doc = Document('test.docx')
paragraph = doc.paragraphs[0]
footnotes = paragraph.footnotes
for footnote in footnotes:
    print(f'footnote reference id: {footnote.id}')
    print(f'this footnote has paragraphs: {len(footnote.paragraphs)}')
  • Can access all footnotes in a document as a list where the list index is footnote reference id for that footnote
doc = Document('test.docx')
for footnote in doc.footnotes:
    print(f'footnote reference id: {footnote.id}')
    print(f'this footnote has paragraphs: {len(footnote.paragraphs)}')
  • Can add a footnote to the end of a paragraph. The footnote reference id is calculated based on the other footnotes in the document. On a created footnote object you can add paragraphs.
doc = Document('test.docx')
paragraph = doc.paragraphs[0]
new_footnote = paragraph.add_footnote()
new_footnote.add_paragraph('paragraph in footnote')
  • Can read and change footnote properties in a section.
doc = Document('test.docx')
s = doc.section[0]
print(s.footnote_position)
print(s.footnote_number_format)
print(s.footnote_numbering_start_value)
print(s.footnote_numbering_restart_location)
s.footnote_position = 'beneathText'
s.footnote_number_format = 'hex'
s.footnote_numbering_start_value = 4
s.footnote_numbering_restart_location = 'eachPage'

@tiberlas tiberlas closed this May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant