AddCarriageReturn not working as expected in NPOI

32 Views Asked by At

In c# program, I am trying to add 3 lines in, but it looks more gap between 2 lines

 XWPFParagraph paragraphTwo = document.CreateParagraph();
        paragraphTwo.Alignment = ParagraphAlignment.LEFT;
        XWPFRun paragraphOneRunTwo = _documnetHelper.CreateAndFormatRun(paragraphTwo, true, 13, WorkflowStepsConstants.FormData.FontCalibri, WorkflowStepsConstants.FormData.FontColorBlack, "Notice");
        paragraphOneRunTwo.AddCarriageReturn();
        paragraphOneRunTwo = _documnetHelper.CreateAndFormatRun(paragraphTwo, false, 13, WorkflowStepsConstants.FormData.FontCalibri, WorkflowStepsConstants.FormData.FontColorBlack, "Date: ");
        paragraphOneRunTwo.AddCarriageReturn();
        paragraphOneRunTwo = _documnetHelper.CreateAndFormatRun(paragraphTwo, false, 13, WorkflowStepsConstants.FormData.FontCalibri, WorkflowStepsConstants.FormData.FontColorBlack, "Number:");


 public XWPFRun CreateAndFormatRun(XWPFParagraph paragraph, bool isBold, double fontSize, string fontFamily, string color, string text)
    {
        XWPFRun run = paragraph.CreateRun();

        run.IsBold = isBold;
        run.FontSize = fontSize;
        run.FontFamily = fontFamily;
        run.SetColor(color);
        if (text != null)
            run.SetText(text);

        return run;
    }

When I set font size 11, all lines look ok with minimal space between them. But if I increase font size to 13 or above, it shows line space may be 1.5 or 2. How to put 3 strings in 3 new lines with minimal space between lines in NPOI? I am using

<PackageReference Include="NPOI" Version="2.6.0" />
0

There are 0 best solutions below