outline_options property

XpsSaveOptions.outline_options property

Allows to specify outline options.

@property
def outline_options(self) -> aspose.words.saving.OutlineOptions:
    ...

Remarks

Note that OutlineOptions.expanded_outline_levels option will not work when saving to XPS.

Examples

Shows how to limit the headings’ level that will appear in the outline of a saved XPS document.

doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
# Insert headings that can serve as TOC entries of levels 1, 2, and then 3.
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING1
self.assertTrue(builder.paragraph_format.is_heading)
builder.writeln('Heading 1')
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING2
builder.writeln('Heading 1.1')
builder.writeln('Heading 1.2')
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING3
builder.writeln('Heading 1.2.1')
builder.writeln('Heading 1.2.2')
# Create an "XpsSaveOptions" object that we can pass to the document's "Save" method
# to modify how that method converts the document to .XPS.
save_options = aw.saving.XpsSaveOptions()
self.assertEqual(aw.SaveFormat.XPS, save_options.save_format)
# The output XPS document will contain an outline, a table of contents that lists headings in the document body.
# Clicking on an entry in this outline will take us to the location of its respective heading.
# Set the "HeadingsOutlineLevels" property to "2" to exclude all headings whose levels are above 2 from the outline.
# The last two headings we have inserted above will not appear.
save_options.outline_options.headings_outline_levels = 2
doc.save(file_name=ARTIFACTS_DIR + 'XpsSaveOptions.OutlineLevels.xps', save_options=save_options)

See Also