'Adding a paragraph on page 2 of a docx through python script
I want to add a small paragraph to my docx file. This I want to do automatically through python script. But when I run my script, it adds it in the last page, instead of the 2nd page .
Can someone please guide me how to correct it :
Here is my code :
def addPage():
p = 1
for paragraph in document.paragraphs:
for run in paragraph.runs:
if 'lastRenderedPageBreak' in run._element.xml:
p+=1
if p==2:
document.add_paragraph('hello world.')
Regards
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
