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 "ParagraphFormat" property.
# 1 -  Create a "TabStop" object, and then add it to the collection:
tab_stop = aw.TabStop(position=aw.ConvertUtil.inch_to_point(3), alignment=aw.TabAlignment.LEFT, leader=aw.TabLeader.DASHES)
paragraph.paragraph_format.tab_stops.add(tab_stop=tab_stop)
# 2 -  Pass the values for properties of a new tab stop to the "Add" method:
paragraph.paragraph_format.tab_stops.add(position=aw.ConvertUtil.millimeter_to_point(100), alignment=aw.TabAlignment.LEFT, leader=aw.TabLeader.DASHES)
# Add tab stops at 5 cm to all paragraphs.
for para in [x.as_paragraph() for x in list(doc.get_child_nodes(aw.NodeType.PARAGRAPH, True)) if isinstance(x.as_paragraph(), aw.Paragraph)]:
    para.paragraph_format.tab_stops.add(position=aw.ConvertUtil.millimeter_to_point(50), alignment=aw.TabAlignment.LEFT, leader=aw.TabLeader.DASHES)
# Every "tab" character takes the builder's cursor to the location of the next tab stop.
builder = aw.DocumentBuilder(doc=doc)
builder.writeln('Start\tTab 1\tTab 2\tTab 3\tTab 4')
doc.save(file_name=ARTIFACTS_DIR + 'TabStopCollection.AddTabStops.docx')

See Also