C# Migra文档PDF页脚样式

C# Migra文档PDF页脚样式,c#,pdf,report,migradoc,C#,Pdf,Report,Migradoc,我在每一页的右边和左边都有一个页脚。页脚中的每个段落包含两行文本。我想要的是在页脚的两行文本之间添加一条水平线 下面是添加页脚的代码 private void AddFooterData(Section section) { // add prepared by. approved by etc var rightFooterSection = new Paragraph { Format = { Alignment = Paragra

我在每一页的右边和左边都有一个页脚。页脚中的每个段落包含两行文本。我想要的是在页脚的两行文本之间添加一条水平线

下面是添加页脚的代码

 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);

    }
下面是所需页脚结果的图片


这是我自己想出来的。 创建一个表,其中包含两列,宽度与页面相同, 创建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);