Migra Doc PDF Стили нижнего колонтитула

У меня есть нижний колонтитул, который идет справа и слева на каждой странице. Каждый абзац нижнего колонтитула содержит 2 строки текста. Я хочу добавить горизонтальную линию между двумя строками текста в нижнем колонтитуле.

Вот код для добавления нижнего колонтитула.

 private void AddFooterData(Section section) {
        // add prepared by. approved by etc

        var rightFooterSection = new Paragraph {
            Format = { Alignment = ParagraphAlignment.Right }
        };
        rightFooterSection.AddText("Prepared By Eng: " + _preparedBy);
        rightFooterSection.AddLineBreak();

        rightFooterSection.AddText("Page ");
        rightFooterSection.AddPageField();
        rightFooterSection.AddText(" / ");
        rightFooterSection.AddNumPagesField();
        section.Footers.Primary.Add(rightFooterSection);

        var date = DateTime.Now.ToString("yyyy/MM/dd");
        var leftSection = new Paragraph {
            Format = { Alignment = ParagraphAlignment.Left }
        };
        leftSection.AddText("Approved By: " + _approvedBy);

        leftSection.AddLineBreak();
        leftSection.AddText(date);
        section.Footers.Primary.Add(leftSection);

    }

вот изображение желаемого результата нижнего колонтитула.

введите здесь описание изображения


person ZZZ    schedule 15.10.2017    source источник


Ответы (1)


Я догадался об этом самостоятельно. Создайте таблицу, содержащую 2 столбца шириной, равной ширине страницы. Создайте 2 строки в верхней строке, установите видимую нижнюю границу. выровняйте текст в каждой строке, чтобы левый столбец был выровнен по левому краю, правый столбец был выровнен по правому краю

private void AddFooterData(Section section) {

        var rightFooterSection = new Paragraph {
            Format = { Alignment = ParagraphAlignment.Right }
        };
        rightFooterSection.AddText("Prepared By Eng: " + _preparedBy);

        var rightFooterPagePar = new Paragraph {
             Format = { Alignment = ParagraphAlignment.Right }
         };
        rightFooterPagePar.AddText("Page ");
        rightFooterPagePar.AddPageField();
        rightFooterPagePar.AddText("/");
        rightFooterPagePar.AddNumPagesField();


        var date = DateTime.Now.ToString("yyyy/MM/dd");
        var leftSection = new Paragraph {
            Format = { Alignment = ParagraphAlignment.Left }
        };
        var leftDateSection = new Paragraph {
            Format = { Alignment = ParagraphAlignment.Left }
        };
        leftSection.AddText("Approved By: " + _approvedBy);
        leftDateSection.AddText(date);
        var footerTable = section.Footers.Primary.AddTable();
        var col1 = footerTable.AddColumn();
        col1.Width = "5.5in";

        var col2 = footerTable.AddColumn();
        col2.Width = "5.5in";
        var row1 = footerTable.AddRow();
        row1[0].Add(leftSection);
        row1[1].Add(rightFooterSection);
        row1.Borders.Bottom.Visible = true;
        row1.Borders.Bottom.Width = "0.10cm";
        var row2 = footerTable.AddRow();
        row2[0].Add(leftDateSection);
        row2[1].Add(rightFooterPagePar);
person ZZZ    schedule 16.10.2017