I am trying to modify word documents using python-docx. Everything is working fine for the documents' body sections, but it gets trickier for the header sections, which I currently am not able to access.
Below is the code I've executed for trying to read the content of the header sections in my document.
import os
from docx import Document
os.chdir('/Users/rtsg/Desktop/Docx')
document = Document('report_v1.docx')
sections = document.sections
for section in document.sections:
header = section.header
for paragraph in header.paragraphs:
print(paragraph.text)
When trying to print the content of the header sections, I get nothing returned (empty strings I guess).
Did someone experience a similar issue and managed to solve it ? Are there some workarounds for modifying the content of the header section ?