how to extract the titles of a document .odt in Libreoffice - Python

422 Views Asked by At

I have a document in the .odt file,

I just want to extract the titles of this document :

in other words , I want to extract the "sentenses " or in others words "the "line" which are in bold in this documentdocument.odt :

my code :

from odf.opendocument import load
from odf import text
from odf import teletype
doc = load('result.odt')

for paragraph in doc.getElementsByType(text.Span):
    print (paragraph.getAttribute('stylename'))
    print(paragraph)

the document is in attached file :

Thank you for your help !

Regards,

0

There are 0 best solutions below