0

I am a complete beginner at python language. For a project I am writing a python script to update a template Open Document File using odfdo module. I am having a hard time with understanding the concept of updating page header. I have looked into Odfdo documentation and found 'get_page_headers' and 'set_page_headers' functions, but have not succeed with its usage.Could someone help me with it?

Thanks

Rojin
  • 1

1 Answers1

0

This works for Libreoffice 6.4:

Get the master-page style. With that style loaded, you can just modify the page header.

from odfdo import Document, Style
doc = Document(testdoc)
# its master-page style has the page-header & footer (returns one element list)
mpstyle = doc.get_styles('master-page')[0]
# get the page_header style, you can take a look at the content
print(mpstyle.get_page_header().serialize())
# Now change the page header
mpstyle.set_page_header('New text')
# save your odt file
doc.save(moddoc, pretty=True)

Regards, Robert

Rob0311
  • 1
  • 1