Migradoc 添加水平线

16

如何在Migradoc中添加一条简单的水平线,以便将线上内容与线下内容分隔开?

段落1

段落2


段落3

等等

3个回答

15

您可以为段落或表格添加边框。

就您的示例而言,您可以为第2段添加底部边框,或为第3段添加顶部边框,或在它们之间添加一个新段落,并设置顶部或底部边框。


11
从这个存储库获取。
        var hr = doc.AddStyle("HorizontalRule", "Normal");
        var hrBorder = new Border();
        hrBorder.Width = "1pt";
        hrBorder.Color = Colors.DarkGray;
        hr.ParagraphFormat.Borders.Bottom = hrBorder;
        hr.ParagraphFormat.LineSpacing = 0;
        hr.ParagraphFormat.SpaceBefore = 15;

4
我需要添加一行代码:myParagraph.Format = hr.ParagraphFormat.Clone(); 这行代码的作用是复制hr段落格式并应用到myParagraph段落。 - Hoppe
1
你应该编辑你的回答,将Hoppe的建议包含进去,因为你发布的代码片段对段落没有任何作用,他的代码是必要的才能使其正常工作。我想编辑它,但无论何时我编辑某些东西,它都会被还原。 - nasch

5
来晚了,但这里有一个示例,演示如何将内容追加到现有段落格式中,而不是像上面的答案一样覆盖它,从而保留已经定义的格式。
Paragraph p = new Paragraph();

p.Format.Alignment = ParagraphAlignment.Center;
//...any other formats needed
p.Format.Borders.Bottom = new Border() { Width = "1pt", Color = Colors.DarkGray };

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接