clear_formatting method

clear_formatting()

Removes all borders of an object.

def clear_formatting(self):
    ...

Examples

Shows how to remove all borders from all paragraphs in a document.

doc = aw.Document(file_name=MY_DIR + 'Borders.docx')
# The first paragraph of this document has visible borders with these settings.
first_paragraph_borders = doc.first_section.body.first_paragraph.paragraph_format.borders
self.assertEqual(aspose.pydrawing.Color.red.to_argb(), first_paragraph_borders.color.to_argb())
self.assertEqual(aw.LineStyle.SINGLE, first_paragraph_borders.line_style)
self.assertEqual(3, first_paragraph_borders.line_width)
# Use the "ClearFormatting" method on each paragraph to remove all borders.
for paragraph in doc.first_section.body.paragraphs:
    paragraph = paragraph.as_paragraph()
    paragraph.paragraph_format.borders.clear_formatting()
    for border in paragraph.paragraph_format.borders:
        self.assertEqual(aspose.pydrawing.Color.empty().to_argb(), border.color.to_argb())
        self.assertEqual(aw.LineStyle.NONE, border.line_style)
        self.assertEqual(0, border.line_width)
doc.save(file_name=ARTIFACTS_DIR + 'BorderCollection.RemoveAllBorders.docx')

See Also