Migradoc Add horizontal line

Late to the game, but here is an example of appending to the existing paragraph format, instead of overwriting as in the answer above, preserving already defined formats:

Paragraph p = new Paragraph();

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

from this repo

        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;

You can add a border to a paragraph or a table.

With respect to your sample, you could add a bottom border to paragraph 2 or add a top border to paragraph 3 or add a new paragraph between them and set either top or bottom border.

Tags:

C#

Migradoc