TabStop
内容
[
隐藏
]TabStop(double)
初始化此类的新实例。
public TabStop(double position)
例子
展示如何使用文档的制表位集合。
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
TabStopCollection tabStops = builder.ParagraphFormat.TabStops;
// 72 点是 Microsoft Word 制表位标尺上的一“英寸”。
tabStops.Add(new TabStop(72.0));
tabStops.Add(new TabStop(432.0, TabAlignment.Right, TabLeader.Dashes));
Assert.AreEqual(2, tabStops.Count);
Assert.IsFalse(tabStops[0].IsClear);
Assert.IsFalse(tabStops[0].Equals(tabStops[1]));
// 每个“制表符”字符都会将构建器的光标移动到下一个制表位的位置。
builder.Writeln("Start\tTab 1\tTab 2");
ParagraphCollection paragraphs = doc.FirstSection.Body.Paragraphs;
Assert.AreEqual(2, paragraphs.Count);
// 每个段落都获取其制表位集合,该集合从文档构建器的制表位集合克隆其值。
Assert.AreEqual(paragraphs[0].ParagraphFormat.TabStops, paragraphs[1].ParagraphFormat.TabStops);
Assert.AreNotSame(paragraphs[0].ParagraphFormat.TabStops, paragraphs[1].ParagraphFormat.TabStops);
// 制表位集合可以将我们指向某些位置之前和之后的制表位。
Assert.AreEqual(72.0, tabStops.Before(100.0).Position);
Assert.AreEqual(432.0, tabStops.After(100.0).Position);
// 我们可以清除段落的制表位集合以恢复默认的制表行为。
paragraphs[1].ParagraphFormat.TabStops.Clear();
Assert.AreEqual(0, paragraphs[1].ParagraphFormat.TabStops.Count);
doc.Save(ArtifactsDir + "TabStopCollection.TabStopCollection.docx");
也可以看看
- class TabStop
- 命名空间 Aspose.Words
- 部件 Aspose.Words
TabStop(double, TabAlignment, TabLeader)
初始化此类的新实例。
public TabStop(double position, TabAlignment alignment, TabLeader leader)
范围 | 类型 | 描述 |
---|---|---|
position | Double | 制表位的位置(以磅为单位)。 |
alignment | TabAlignment | ATabAlignment 值 that 指定此制表位处的文本对齐方式。 |
leader | TabLeader | ATabLeader 指定 制表符下显示的引导线类型的值。 |
例子
展示如何使用文档的制表位集合。
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
TabStopCollection tabStops = builder.ParagraphFormat.TabStops;
// 72 点是 Microsoft Word 制表位标尺上的一“英寸”。
tabStops.Add(new TabStop(72.0));
tabStops.Add(new TabStop(432.0, TabAlignment.Right, TabLeader.Dashes));
Assert.AreEqual(2, tabStops.Count);
Assert.IsFalse(tabStops[0].IsClear);
Assert.IsFalse(tabStops[0].Equals(tabStops[1]));
// 每个“制表符”字符都会将构建器的光标移动到下一个制表位的位置。
builder.Writeln("Start\tTab 1\tTab 2");
ParagraphCollection paragraphs = doc.FirstSection.Body.Paragraphs;
Assert.AreEqual(2, paragraphs.Count);
// 每个段落都获取其制表位集合,该集合从文档构建器的制表位集合克隆其值。
Assert.AreEqual(paragraphs[0].ParagraphFormat.TabStops, paragraphs[1].ParagraphFormat.TabStops);
Assert.AreNotSame(paragraphs[0].ParagraphFormat.TabStops, paragraphs[1].ParagraphFormat.TabStops);
// 制表位集合可以将我们指向某些位置之前和之后的制表位。
Assert.AreEqual(72.0, tabStops.Before(100.0).Position);
Assert.AreEqual(432.0, tabStops.After(100.0).Position);
// 我们可以清除段落的制表位集合以恢复默认的制表行为。
paragraphs[1].ParagraphFormat.TabStops.Clear();
Assert.AreEqual(0, paragraphs[1].ParagraphFormat.TabStops.Count);
doc.Save(ArtifactsDir + "TabStopCollection.TabStopCollection.docx");
也可以看看
- enum TabAlignment
- enum TabLeader
- class TabStop
- 命名空间 Aspose.Words
- 部件 Aspose.Words