simplify_list_labels property
TxtSaveOptions.simplify_list_labels property
Specifies whether the program should simplify list labels in case of complex label formatting not being adequately represented by plain text.
If set to True, numbered list labels are written in simple numeric format
and itemized list labels as simple ASCII characters. The default value is False.
@property
def simplify_list_labels(self) -> bool:
...
@simplify_list_labels.setter
def simplify_list_labels(self, value: bool):
...
Examples
Shows how to change the appearance of lists when saving a document to plaintext.
doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
# Create a bulleted list with five levels of indentation.
builder.list_format.apply_bullet_default()
builder.writeln('Item 1')
builder.list_format.list_indent()
builder.writeln('Item 2')
builder.list_format.list_indent()
builder.writeln('Item 3')
builder.list_format.list_indent()
builder.writeln('Item 4')
builder.list_format.list_indent()
builder.write('Item 5')
# Create a "TxtSaveOptions" object, which we can pass to the document's "Save" method
# to modify how we save the document to plaintext.
txt_save_options = aw.saving.TxtSaveOptions()
# Set the "SimplifyListLabels" property to "true" to convert some list
# symbols into simpler ASCII characters, such as '*', 'o', '+', '>', etc.
# Set the "SimplifyListLabels" property to "false" to preserve as many original list symbols as possible.
txt_save_options.simplify_list_labels = simplify_list_labels
doc.save(file_name=ARTIFACTS_DIR + 'TxtSaveOptions.SimplifyListLabels.txt', save_options=txt_save_options)
doc_text = system_helper.io.File.read_all_text(ARTIFACTS_DIR + 'TxtSaveOptions.SimplifyListLabels.txt')
new_line = system_helper.environment.Environment.new_line()
if simplify_list_labels:
self.assertEqual(f'* Item 1{new_line}' + f' > Item 2{new_line}' + f' + Item 3{new_line}' + f' - Item 4{new_line}' + f' o Item 5{new_line}', doc_text)
else:
self.assertEqual(f'· Item 1{new_line}' + f'o Item 2{new_line}' + f'§ Item 3{new_line}' + f'· Item 4{new_line}' + f'o Item 5{new_line}', doc_text)
See Also
- module aspose.words.saving
- class TxtSaveOptions