Python-DocX horizontal line in document title

143 Views Asked by At

In python-docx, when we add a document title as below, it automatically add a horizontal line under the title. It seems to be a border. May you know how to remove it ? Thank you.

main_title = self.document.add_heading(self.doc_title, 0)

exemple of the problem

1

There are 1 best solutions below

0
ilyasub3 On

this solution worked for me:

title = doc.add_heading('My Heading', 0)
title_style = title.style
title_style.paragraph_format._element.xpath('.//w:pBdr')[0].getparent().remove(
    title_style.paragraph_format._element.xpath('.//w:pBdr')[0])