MigraDoc 将页脚文本框架绝对定位到底部页面边缘



我需要将页脚与每个页面的绝对底部对齐并跨越整个页面。

我使用了文本框架,因为它可以是绝对定位的,所以会忽略我的页边距,我可以让它完全穿过页面,但我不能让它坐在底部。

我试过:

  fr.Top =  *any number*; 
  fr.Top = ShapePosition.Bottom;

这些都不会导致它移动

 fr.RelativeVertical = RelativeVertical.Page;

这使它完美地位于顶部,但我需要它在底部

我想我需要对它进行偏移,但我不知道如何应用它,因为顶部属性对我没有任何作用。

我的页面设置如下:

        section.PageSetup.PageFormat = PageFormat.A4;
        section.PageSetup.OddAndEvenPagesHeaderFooter = true;
        AddFooter(ref section);
        section.PageSetup.LeftMargin = "1 cm";
        section.PageSetup.TopMargin = "1 cm";
        section.PageSetup.RightMargin = "1 cm";
        section.PageSetup.BottomMargin = "1 cm";
        section.PageSetup.HeaderDistance = "1 cm";
        section.PageSetup.FooterDistance = "0 cm";

使用这样的添加页脚:

 public static void AddFooter(ref Section section)
    {
        Unit pageWidth = GetWidth(section);<- custom function
        TextFrame fr = new TextFrame();
        var footerTable = fr.AddTable();
      ~~footer table info here~~
        fr.Width = new Unit(pageWidth);
        fr.MarginLeft = new Unit(4);//set as 4 because for some reason it as
       sitting slightly to the left
         /**
      SET BOTTOM POSITION HERE
        **/
     fr.RelativeHorizontal = RelativeHorizontal.Page;//This makes it sit to the left of the page
        section.Footers.Primary.Add(fr.Clone());
        section.Footers.EvenPage.Add(fr.Clone());
    }

不要设置TextFrameTop 属性,而是设置 WrapFormat.DistanceTop 属性。此外,将 WrapFormat.Style 属性设置为 WrapStyle.Through
另请参阅:https://forum.pdfsharp.net/viewtopic.php?p=6922#p6922

AFAIK 如果将表的 Rows.LeftIndent 属性设置为 0,则不必设置框架的 MarginLeft 属性。默认情况下,表格具有负缩进,以便表格中的文本与表格外的文本对齐。

最新更新