pdf-generationpdfsharpparagraphmigradocline-spacing

MigraDoc: How to apply vertical line spacing to a paragraph?


I am creating a PDF using MigraDoc. Everything works fine except the setting of line spacing of a paragraph. I want to have more vertical space between paragraph lines.

What I tried so far without any change in the resulting PDF:

string text = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";

Paragraph para = CreateParagraph(text , "Helvetica", 7, "0.1mm", Colors.Black, ParagraphAlignment.Left);

// tried this:
para.Format.LineSpacing = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(12);

// and tried that:
para.Format.LineSpacing = 12;

Can anyone point me in the right direction?


Solution

  • The meaning of LineSpacing depends on the value set for LineSpacingRule.

    If LineSpacingRule is set to e.g. Single or Double then the value set for LineSpacing will be ignored.

    Try AtLeast or Exactly for LineSpacingRule.