body.append(title1) for p in range(3): title = Header(2, random_text(1)[:70]) body.append(title) paragraph = Paragraph(random_text(10)) # Adding Footnote # Now we add a footnote on each paragraph # Notes are quite complex so they deserve a dedicated API on paragraphs: some_word = paragraph.text_recursive.split()[3] # choosing the 4th word of the paragraph to insert the note paragraph.insert_note( after=some_word, # The word after what the “¹” citation is inserted. note_id=f"note{p}", # The unique identifier of the note in the document. citation="1", # The symbol the user sees to follow the footnote. body=( f'Author{p}, A. (2007). "How to cite references", Sample Editions.' # The footnote itself, at the end of the page. ), ) body.append(paragraph) if not os.path.exists("test_output"): os.mkdir("test_output") output = os.path.join("test_output", "my_document_with_footnote.odt") # And finally save the document. my_document.save(target=output, pretty=True)
# Creation / Insertion table = Table("table1", width=2, height=2, style="Standard") table.set_values(data) body.append(table) # 3- Description (=> footnote & => highlight) # ------------------------------------------- heading = Header(1, text="Description") body.append(heading) # A paragraph with a note text = "The odfdo project is made to generate easily OpenDocuments." paragraph = Paragraph(text, style="Standard") paragraph.insert_note( after="odfdo project", note_id="note1", citation="1", body="http://xxxxxxxxxxxx/" ) body.append(paragraph) # A paragraph with a highlighted word # The style style = Style( "text", "style2", parent="Standard", area="text", background_color=rgb2hex("yellow") ) document.insert_style(style) # The paragraph text = ( "The office document file format OpenDocument Format (ODF) " "is an ISO standard ISO 26300 used by many applications."
from odfdo import Document, Paragraph document = Document('text') body = document.body paragraph = Paragraph(('A paragraph with a footnote ' 'about references in it.')) body.append(paragraph) # Notes are quite complex so they deserve a dedicated API on paragraphs: paragraph.insert_note(after="graph", note_id='note1', citation="1", body=('Author, A. (2007). "How to cite references", ' 'New York: McGraw-Hill.')) # That looks complex so we detail the arguments: # # after => The word after what the “¹” citation is inserted. # note_id => The unique identifier of the note in the document. # citation => The symbol the user sees to follow the footnote. # body => The footnote itself, at the end of the page. # # odfdo creates footnotes by default. To create endnotes (notes # that appear at the end of the document), give the # note_class=’endnote’ parameter.
# Creation / Insertion table = Table('table1', width=2, height=2, style="Standard") table.set_values(data) body.append(table) # 3- Description (=> footnote & => highlight) # ------------------------------------------- heading = Header(1, text='Description') body.append(heading) # A paragraph with a note text = 'The odfdo project is made to generate easily OpenDocuments.' paragraph = Paragraph(text, style="Standard") paragraph.insert_note(after="odfdo project", note_id='note1', citation='1', body='http://xxxxxxxxxxxx/') body.append(paragraph) # A paragraph with a highlighted word # The style style = Style('text', "style2", parent="Standard", area='text', background_color=rgb2hex('yellow')) document.insert_style(style) # The paragraph text = ('The office document file format OpenDocument Format (ODF) '