Aspose::Words::TabStopCollection::Add method

TabStopCollection::Add(const System::SharedPtr<Aspose::Words::TabStop>&) method

Adds or replaces a tab stop in the collection.

void Aspose::Words::TabStopCollection::Add(const System::SharedPtr<Aspose::Words::TabStop> &tabStop)
ParameterTypeDescription
tabStopconst System::SharedPtr<Aspose::Words::TabStop>&A tab stop object to add.

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.

auto doc = MakeObject<Document>();
auto paragraph = System::ExplicitCast<Paragraph>(doc->GetChild(NodeType::Paragraph, 0, true));

// 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:
auto tabStop = MakeObject<TabStop>(ConvertUtil::InchToPoint(3), TabAlignment::Left, TabLeader::Dashes);
paragraph->get_ParagraphFormat()->get_TabStops()->Add(tabStop);

// 2 -  Pass the values for properties of a new tab stop to the "Add" method:
paragraph->get_ParagraphFormat()->get_TabStops()->Add(ConvertUtil::MillimeterToPoint(100), TabAlignment::Left, TabLeader::Dashes);

// Add tab stops at 5 cm to all paragraphs.
for (const auto& para : System::IterateOver(doc->GetChildNodes(NodeType::Paragraph, true)->LINQ_OfType<SharedPtr<Paragraph>>()))
{
    para->get_ParagraphFormat()->get_TabStops()->Add(ConvertUtil::MillimeterToPoint(50), TabAlignment::Left, TabLeader::Dashes);
}

// Every "tab" character takes the builder's cursor to the location of the next tab stop.
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Start\tTab 1\tTab 2\tTab 3\tTab 4");

doc->Save(ArtifactsDir + u"TabStopCollection.AddTabStops.docx");

See Also

TabStopCollection::Add(double, Aspose::Words::TabAlignment, Aspose::Words::TabLeader) method

Adds or replaces a tab stop in the collection.

void Aspose::Words::TabStopCollection::Add(double position, Aspose::Words::TabAlignment alignment, Aspose::Words::TabLeader leader)
ParameterTypeDescription
positiondoubleA position (in points) where to add the tab stop.
alignmentAspose::Words::TabAlignmentA TabAlignment value that specifies the alignment of text at the tab stop.
leaderAspose::Words::TabLeaderA 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.

auto doc = MakeObject<Document>();
auto paragraph = System::ExplicitCast<Paragraph>(doc->GetChild(NodeType::Paragraph, 0, true));

// 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:
auto tabStop = MakeObject<TabStop>(ConvertUtil::InchToPoint(3), TabAlignment::Left, TabLeader::Dashes);
paragraph->get_ParagraphFormat()->get_TabStops()->Add(tabStop);

// 2 -  Pass the values for properties of a new tab stop to the "Add" method:
paragraph->get_ParagraphFormat()->get_TabStops()->Add(ConvertUtil::MillimeterToPoint(100), TabAlignment::Left, TabLeader::Dashes);

// Add tab stops at 5 cm to all paragraphs.
for (const auto& para : System::IterateOver(doc->GetChildNodes(NodeType::Paragraph, true)->LINQ_OfType<SharedPtr<Paragraph>>()))
{
    para->get_ParagraphFormat()->get_TabStops()->Add(ConvertUtil::MillimeterToPoint(50), TabAlignment::Left, TabLeader::Dashes);
}

// Every "tab" character takes the builder's cursor to the location of the next tab stop.
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln(u"Start\tTab 1\tTab 2\tTab 3\tTab 4");

doc->Save(ArtifactsDir + u"TabStopCollection.AddTabStops.docx");

See Also