Click or drag to resize
TabStop Structure
Represents a single custom tab stop within a set of custom tab stops applied at ParagraphFormat.Tabs property.

Namespace: GemBox.Document
Assembly: GemBox.Document (in GemBox.Document.dll) Version: 25.3.30.1231
Syntax
public struct TabStop : IEquatable<TabStop>

The TabStop type exposes the following members.

Constructors
  NameDescription
Public methodTabStop(Double, TabStopAlignment)
Initializes a new instance of the TabStop struct.
Public methodTabStop(Double, TabStopAlignment, TabStopLeader)
Initializes a new instance of the TabStop struct.
Top
Methods
  NameDescription
Public methodEquals(Object)
Determines whether the specified Object is equal to this TabStop instance.
(Overrides ValueTypeEquals(Object).)
Public methodEquals(TabStop)
Determines whether the other TabStop is equal to this TabStop instance.
Public methodGetHashCode
Returns a hash code for this TabStop instance.
(Overrides ValueTypeGetHashCode.)
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Determines whether first and second TabStops are equal.
Public operatorStatic memberInequality
Determines whether first and second TabStops are not equal.
Top
Properties
  NameDescription
Public propertyAlignment
Gets the alignment of the current TabStop, which determines the behavior of the tab stop and the alignment which shall be applied to text entered at the current TabStop.
Public propertyLeader
Gets the character which shall be used to fill in the space created by a tab which ends at this TabStop.
Public propertyPosition
Gets the position of the current TabStop, in points, with respect to the current page margins.
Top
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