ParagraphFormatTabStops Property

Gets the collection of custom tab stops defined for this object.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public TabStopCollection TabStops { get; }

Property Value

Type: TabStopCollection
Examples
Shows how to modify the position of the right tab stop in TOC related paragraphs.
Document doc = new Document(MyDir + "Table of contents.docx");

// Iterate through all paragraphs in the document
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true).OfType<Paragraph>())
{
    // Check if this paragraph is formatted using the TOC result based styles. This is any style between TOC and TOC9
    if (para.ParagraphFormat.Style.StyleIdentifier >= StyleIdentifier.Toc1 &&
        para.ParagraphFormat.Style.StyleIdentifier <= StyleIdentifier.Toc9)
    {
        // Get the first tab used in this paragraph, this should be the tab used to align the page numbers
        TabStop tab = para.ParagraphFormat.TabStops[0];
        // Remove the old tab from the collection
        para.ParagraphFormat.TabStops.RemoveByPosition(tab.Position);
        // Insert a new tab using the same properties but at a modified position
        // We could also change the separators used (dots) by passing a different Leader type
        para.ParagraphFormat.TabStops.Add(tab.Position - 50, tab.Alignment, tab.Leader);
    }
}

doc.Save(ArtifactsDir + "Styles.ChangeTocsTabStops.docx");
See Also