automatically_update property
Style.automatically_update property
Specifies whether this style is automatically redefined based on the appropriate value.
@property
def automatically_update(self) -> bool:
...
@automatically_update.setter
def automatically_update(self, value: bool):
...
Remarks
If the property value is set to true, MS Word automatically redefines the current style when the appropriate paragraph formatting has been changed.
AutomaticallyUpdate property is applicable to paragraph styles only.
The default value is False
.
Examples
Shows how to create and apply a custom style.
doc = aw.Document()
style = doc.styles.add(aw.StyleType.PARAGRAPH, 'MyStyle')
style.font.name = 'Times New Roman'
style.font.size = 16
style.font.color = aspose.pydrawing.Color.navy
# Automatically redefine style.
style.automatically_update = True
builder = aw.DocumentBuilder(doc)
# Apply one of the styles from the document to the paragraph that the document builder is creating.
builder.paragraph_format.style = doc.styles.get_by_name('MyStyle')
builder.writeln('Hello world!')
first_paragraph_style = doc.first_section.body.first_paragraph.paragraph_format.style
self.assertEqual(style, first_paragraph_style)
# Remove our custom style from the document's styles collection.
doc.styles.get_by_name('MyStyle').remove()
first_paragraph_style = doc.first_section.body.first_paragraph.paragraph_format.style
# Any text that used a removed style reverts to the default formatting.
self.assertFalse(any((s.name == 'MyStyle' for s in doc.styles)))
self.assertEqual('Times New Roman', first_paragraph_style.font.name)
self.assertEqual(12.0, first_paragraph_style.font.size)
self.assertEqual(aspose.pydrawing.Color.empty().to_argb(), first_paragraph_style.font.color.to_argb())
See Also
- module aspose.words
- class Style