Click or drag to resize
ParagraphFormatTabs Property
Gets the TabStops collection.

Namespace: GemBox.Document
Assembly: GemBox.Document (in GemBox.Document.dll) Version: 25.3.30.1231
Syntax
public TabStopCollection Tabs { get; }

Property Value

Type: TabStopCollection
The TabStops collection.
Remarks

Creating customized tabs in a document is accomplished with TabStop structure that enables you to define tab position, tab leader character and surrounding text alignment.

TabStops should be inserted into ParagraphFormat.Tabs collection to be used in a Paragraph.

Tabs are inserted into a document content with SpecialCharacter elements that have SpecialCharacter.CharacterType property equal to Tab.

Values Bar and List are currently not supported in PDF, XPS and image file formats.

Examples

Following example shows how to define customized tab stops and insert the tabs in document content.

// Create a new empty document.
var doc = new DocumentModel();

// Define document content and paragraph formatting in one code statement.
doc.Sections.Add(
    new Section(doc,
        new Paragraph(doc,
            // Add two lines of text: first with text and tabs, second with only tabs - so tab stop position, tab stop alignment and tab stop leader values can be observed more closely.
            new Run(doc, "First"),
            new SpecialCharacter(doc, SpecialCharacterType.Tab),
            new Run(doc, "Second"),
            new SpecialCharacter(doc, SpecialCharacterType.Tab),
            new Run(doc, "Third"),
            new SpecialCharacter(doc, SpecialCharacterType.Tab),
            new Run(doc, "Fourth"),
            new SpecialCharacter(doc, SpecialCharacterType.LineBreak),
            new SpecialCharacter(doc, SpecialCharacterType.Tab),
            new SpecialCharacter(doc, SpecialCharacterType.Tab),
            new SpecialCharacter(doc, SpecialCharacterType.Tab))
        {
            ParagraphFormat = new ParagraphFormat()
            {
                Tabs =
                {
                    // Define three tab stops, with different alignments and leader characters, each ending 1000 points after the previous one.
                    new TabStop(100, TabStopAlignment.Left, TabStopLeader.Dot),
                    new TabStop(200, TabStopAlignment.Center, TabStopLeader.Hyphen),
                    new TabStop(300, TabStopAlignment.Right, TabStopLeader.Underscore)
                }
            }
        }));

// Document will be saved on the Desktop.
var path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "TabStops.docx");

// Save the document.
doc.Save(path);

// Open the document in Microsoft Word.
System.Diagnostics.Process.Start(path);
See Also