SpaceBefore
内容
[
隐藏
]ParagraphFormat.SpaceBefore property
获取或设置段落前的间距量(以点为单位)。
public double SpaceBefore { get; set; }
例外
例外 | (健康)状况 |
---|---|
ArgumentOutOfRangeException | 当参数超出有效值范围时抛出。 |
评论
无效SpaceBeforeAuto
是真的
。
有效值范围为 0 至 1584(含)。
例子
显示如何设置自动段落间距。
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// 在该构建器将创建的段落前后应用大量间距。
builder.ParagraphFormat.SpaceBefore = 24;
builder.ParagraphFormat.SpaceAfter = 24;
// 将这些标志设置为“true”以应用自动间距,
// 有效地忽略了我们上面设置的属性中的间距。
// 将它们保留为“false”将应用我们的自定义段落间距。
builder.ParagraphFormat.SpaceAfterAuto = autoSpacing;
builder.ParagraphFormat.SpaceBeforeAuto = autoSpacing;
// 插入两个上下有间距的段落并保存文档。
builder.Writeln("Paragraph 1.");
builder.Writeln("Paragraph 2.");
doc.Save(ArtifactsDir + "ParagraphFormat.ParagraphSpacingAuto.docx");
展示如何在相同样式的段落之间不应用间距。
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// 在该构建器将创建的段落前后应用大量间距。
builder.ParagraphFormat.SpaceBefore = 24;
builder.ParagraphFormat.SpaceAfter = 24;
// 将“NoSpaceBetweenParagraphsOfSameStyle”标志设置为“true”以应用
// 相同样式的段落之间没有间距,这会将相似的段落分组。
// 将“NoSpaceBetweenParagraphsOfSameStyle”标志保留为“false”
// 均匀地将间距应用于每个段落。
builder.ParagraphFormat.NoSpaceBetweenParagraphsOfSameStyle = noSpaceBetweenParagraphsOfSameStyle;
builder.ParagraphFormat.Style = doc.Styles["Normal"];
builder.Writeln($"Paragraph in the \"{builder.ParagraphFormat.Style.Name}\" style.");
builder.Writeln($"Paragraph in the \"{builder.ParagraphFormat.Style.Name}\" style.");
builder.Writeln($"Paragraph in the \"{builder.ParagraphFormat.Style.Name}\" style.");
builder.ParagraphFormat.Style = doc.Styles["Quote"];
builder.Writeln($"Paragraph in the \"{builder.ParagraphFormat.Style.Name}\" style.");
builder.Writeln($"Paragraph in the \"{builder.ParagraphFormat.Style.Name}\" style.");
builder.ParagraphFormat.Style = doc.Styles["Normal"];
builder.Writeln($"Paragraph in the \"{builder.ParagraphFormat.Style.Name}\" style.");
builder.Writeln($"Paragraph in the \"{builder.ParagraphFormat.Style.Name}\" style.");
doc.Save(ArtifactsDir + "ParagraphFormat.ParagraphSpacingSameStyle.docx");
也可以看看
- class ParagraphFormat
- 命名空间 Aspose.Words
- 部件 Aspose.Words