add method

add(tab_stop)

Adds or replaces a tab stop in the collection.

def add(self, tab_stop: aspose.words.TabStop):
    ...
ParameterTypeDescription
tab_stopTabStopA tab stop object to add.

Remarks

If a tab stop already exists at the specified position, it is replaced.

add(position, alignment, leader)

Adds or replaces a tab stop in the collection.

def add(self, position: float, alignment: aspose.words.TabAlignment, leader: aspose.words.TabLeader):
    ...
ParameterTypeDescription
positionfloatA position (in points) where to add the tab stop.
alignmentTabAlignmentA TabAlignment value that specifies the alignment of text at the tab stop.
leaderTabLeaderA TabLeader value that specifies the type of the leader line displayed under the tab character.

Remarks

If a tab stop already exists at the specified position, it is replaced.

Examples

Shows how to add custom tab stops to a document.

doc = aw.Document()
paragraph = doc.get_child(aw.NodeType.PARAGRAPH, 0, True).as_paragraph()

# Below are two ways of adding tab stops to a paragraph's collection of tab stops via the "paragraph_format" property.
# 1 -  Create a "TabStop" object, and then add it to the collection:
tab_stop = aw.TabStop(aw.ConvertUtil.inch_to_point(3), aw.TabAlignment.LEFT, aw.TabLeader.DASHES)
paragraph.paragraph_format.tab_stops.add(tab_stop)

# 2 -  Pass the values for properties of a new tab stop to the "add" method:
paragraph.paragraph_format.tab_stops.add(aw.ConvertUtil.millimeter_to_point(100),
                                         aw.TabAlignment.LEFT, aw.TabLeader.DASHES)

# Add tab stops at 5 cm to all paragraphs.
for para in doc.get_child_nodes(aw.NodeType.PARAGRAPH, True):
    para = para.as_paragraph()
    para.paragraph_format.tab_stops.add(aw.ConvertUtil.millimeter_to_point(50),
                                        aw.TabAlignment.LEFT, aw.TabLeader.DASHES)

# Every "tab" character takes the builder's cursor to the location of the next tab stop.
builder = aw.DocumentBuilder(doc)
builder.writeln("Start\tTab 1\tTab 2\tTab 3\tTab 4")

doc.save(ARTIFACTS_DIR + "TabStopCollection.add_tab_stops.docx")

See Also