How can I add a simple horizontal line in Migradoc so as to separate the content above the line from the content below the line?
Paragraph 1
Paragraph 2
Paragraph 3
ETC
How can I add a simple horizontal line in Migradoc so as to separate the content above the line from the content below the line?
Paragraph 1
Paragraph 2
Paragraph 3
ETC
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.
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;
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 };
© 2022 - 2024 — McMap. All rights reserved.