AbsolutePositionTab
Contents
[
Hide
]AbsolutePositionTab class
An absolute position tab is a character which is used to advance the position on the current line of text when displaying this WordprocessingML content.
To learn more, visit the Aspose.Words Document Object Model (DOM) documentation article.
public class AbsolutePositionTab : SpecialChar
Properties
Name | Description |
---|---|
CustomNodeId { get; set; } | Specifies custom node identifier. |
virtual Document { get; } | Gets the document to which this node belongs. |
Font { get; } | Provides access to the font formatting of this object. |
virtual IsComposite { get; } | Returns true if this node can contain other nodes. |
IsDeleteRevision { get; } | Returns true if this object was deleted in Microsoft Word while change tracking was enabled. |
IsFormatRevision { get; } | Returns true if formatting of the object was changed in Microsoft Word while change tracking was enabled. |
IsInsertRevision { get; } | Returns true if this object was inserted in Microsoft Word while change tracking was enabled. |
IsMoveFromRevision { get; } | Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled. |
IsMoveToRevision { get; } | Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled. |
NextSibling { get; } | Gets the node immediately following this node. |
override NodeType { get; } | Returns SpecialChar. |
ParentNode { get; } | Gets the immediate parent of this node. |
ParentParagraph { get; } | Retrieves the parent Paragraph of this node. |
PreviousSibling { get; } | Gets the node immediately preceding this node. |
Range { get; } | Returns a Range object that represents the portion of a document that is contained in this node. |
Methods
Name | Description |
---|---|
override Accept(DocumentVisitor) | Accepts a visitor. |
Clone(bool) | Creates a duplicate of the node. |
GetAncestor(NodeType) | Gets the first ancestor of the specified NodeType . |
GetAncestor(Type) | Gets the first ancestor of the specified object type. |
override GetText() | Gets the special character that this node represents. |
NextPreOrder(Node) | Gets next node according to the pre-order tree traversal algorithm. |
PreviousPreOrder(Node) | Gets the previous node according to the pre-order tree traversal algorithm. |
Remove() | Removes itself from the parent. |
ToString(SaveFormat) | Exports the content of the node into a string in the specified format. |
ToString(SaveOptions) | Exports the content of the node into a string using the specified save options. |
Examples
Shows how to process absolute position tab characters with a document visitor.
public void DocumentToTxt()
{
Document doc = new Document(MyDir + "Absolute position tab.docx");
// Extract the text contents of our document by accepting this custom document visitor.
DocTextExtractor myDocTextExtractor = new DocTextExtractor();
Section fisrtSection = doc.FirstSection;
fisrtSection.Body.Accept(myDocTextExtractor);
// Visit only start of the document body.
fisrtSection.Body.AcceptStart(myDocTextExtractor);
// Visit only end of the document body.
fisrtSection.Body.AcceptEnd(myDocTextExtractor);
// The absolute position tab, which has no equivalent in string form, has been explicitly converted to a tab character.
Assert.AreEqual("Before AbsolutePositionTab\tAfter AbsolutePositionTab", myDocTextExtractor.GetText());
// An AbsolutePositionTab can accept a DocumentVisitor by itself too.
AbsolutePositionTab absPositionTab = (AbsolutePositionTab)doc.FirstSection.Body.FirstParagraph.GetChild(NodeType.SpecialChar, 0, true);
myDocTextExtractor = new DocTextExtractor();
absPositionTab.Accept(myDocTextExtractor);
Assert.AreEqual("\t", myDocTextExtractor.GetText());
}
/// <summary>
/// Collects the text contents of all runs in the visited document. Replaces all absolute tab characters with ordinary tabs.
/// </summary>
public class DocTextExtractor : DocumentVisitor
{
public DocTextExtractor()
{
mBuilder = new StringBuilder();
}
/// <summary>
/// Called when a Run node is encountered in the document.
/// </summary>
public override VisitorAction VisitRun(Run run)
{
AppendText(run.Text);
return VisitorAction.Continue;
}
/// <summary>
/// Called when an AbsolutePositionTab node is encountered in the document.
/// </summary>
public override VisitorAction VisitAbsolutePositionTab(AbsolutePositionTab tab)
{
mBuilder.Append("\t");
return VisitorAction.Continue;
}
/// <summary>
/// Adds text to the current output. Honors the enabled/disabled output flag.
/// </summary>
private void AppendText(string text)
{
mBuilder.Append(text);
}
/// <summary>
/// Plain text of the document that was accumulated by the visitor.
/// </summary>
public string GetText()
{
return mBuilder.ToString();
}
private readonly StringBuilder mBuilder;
}
See Also
- class SpecialChar
- namespace Aspose.Words
- assembly Aspose.Words