Need python code for adding TOC, defining styles for Heading 1

I am exploring Python UNO for automating ebooks making using LibreOffice for

The workflow is as below.

  1. Authors send us word file and a cover image
  2. We should mark all chapter heading as “Heading 1, Heading 2” etc

Then a python script should do the following

  1. Add cover image in first page
  2. Change all content font to “Vijaya” (a Tamil language font) and size 12
  3. Change all Heading1 to font size 16, set blue color, add a red line below it
  4. Add footer and add page number ( I have code for this)
  5. Add Table of Content in page 3
  6. Save as PDF ( I have code for this)

Please help to get it done using python.
Guide me the required components, properties to use with python.


Kindly make an attempt to write the code first before asking, and then post relevant parts of your code. Also, there is a great deal of information about these things already online. Edit the question to mention what you have found. See the first bullet point under guidelines for asking.

Your requirement looks like the definition of styles or template. Apart from your desire to learn Python LO code, wouldn’t it be simpler to send a template to authors, even if many use M$ Office?