Migradoc Add horizontal line
Asked Answered
F

3

16

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

Fredelia answered 26/8, 2013 at 8:51 Comment(0)
J
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.

Judejudea answered 26/8, 2013 at 16:10 Comment(0)
D
11

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;
Dewy answered 18/6, 2015 at 5:39 Comment(2)
I also had to add a line myParagraph.Format = hr.ParagraphFormat.Clone();Whistler
You should edit your answer to include Hoppe's suggestion as the code snippet you posted doesn't do anything to the paragraph and his code is necessary to make it work. I would edit it, but any time I edit something it gets reverted anyway.Executrix
A
6

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 };
Aday answered 11/12, 2019 at 20:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.