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'

@Cerebex
Copy link

Cerebex commented Oct 28, 2024

@scanny Any updates on merging footnote support into the library?

@Cerebex
Copy link

Cerebex commented Oct 29, 2024

@tiberlas I tested this update locally and it works great. I wish it was merged since being able to pull footnotes from the exact paragraph that they are referenced in great!

@scanny Happy to help with work to merge this into main if you would like support.

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.

2 participants