Python-DocX 文档标题中的水平线

问题描述 投票:0回答:1

在python-docx中,当我们添加如下文档标题时,它会自动在标题下方添加一条水平线。这似乎是一个边界。你知道如何删除它吗?谢谢你。

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

python border python-docx heading horizontal-line
1个回答
0
投票

这个解决方案对我有用:

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])
© www.soinside.com 2019 - 2024. All rights reserved.