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

Feature footnote support #1392

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

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'

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