Click or drag to resize
TabStopAlignment Enumeration
Represents the available alignments for custom TabStop, which determines the behavior of the TabStop and the alignment which shall be applied to text entered at the current custom TabStop.

Namespace:  GemBox.Document
Assembly:  GemBox.Document (in GemBox.Document.dll) Version: 25.3.30.1243
Syntax
public enum TabStopAlignment
Members
  Member nameValueDescription
None0 Specifies that the current tab stop is cleared and shall be removed and ignored when processing the contents of the document.
Left1 Specifies that the current tab stop shall result in a location in the document where all following text is left aligned (i.e. all text runs following this tab stop and preceding the next tab stop shall be left aligned with respect to the tab stop location).
Center2 Specifies that the current tab stop shall result in a location in the document where all following text is centered (i.e. all text runs following this tab stop and preceding the next tab stop shall be centered around the tab stop location).
Right3 Specifies that the current tab stop shall result in a location in the document where all following text is right aligned (i.e. all text runs following this tab stop and preceding the next tab stop shall be right aligned with respect to the tab stop location).
Decimal4 Specifies that the current tab stop shall result in a location in the document where all following text is aligned around the first decimal character in the following text runs. All text runs before the first decimal character shall be before the tab stop, all text runs after it shall be after the tab stop location.
Bar5 Specifies that the current tab is a bar tab. A bar tab is a tab which does not result in a custom tab stop in the parent paragraph (this tab stop location shall be skipped when positioning custom tab characters), but instead shall be used to draw a vertical line (or bar) at this location in the parent paragraph.
List6 Specifies that the current tab is a list tab, which is the tab stop between the numbering and the paragraph contents in a numbered paragraph.
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