-2

I am trying to insert a paragraph before TOC using python-docx. Is there a way in which I can add the paragraph before the TOC.

This is what currently I have

This is what currently I have

I want something like this

enter image description here

macropod
  • 12,757
  • 2
  • 9
  • 21
  • You need to show your code so that people can try it and find how to make it work. See [ask]. – Robert Jun 29 '21 at 16:08

1 Answers1

0

Have you tried this?:

paragraph = document.paragraphs[0].insert_paragraph_before(
    "New paragraph here"
)
scanny
  • 26,423
  • 5
  • 54
  • 80
  • yes I have tried this. The TOC is the very first thing on the first page. So the text (New paragraph here) gets added after the TOC. – yukta sarode Jun 30 '21 at 05:07
  • You should add those details to your question. It shows you've tried some things and gives a respondent more to go on to help you. – scanny Jun 30 '21 at 06:29