我需要使页脚与每页的绝对底部对齐并跨越整个页面。
我使用了一个文本框,因为它可以绝对定位,因此将忽略我的页面边距,我可以在整个页面上完全获取它,但是我不能让它位于底部。
我尝试过:
fr.Top = *any number*;
fr.Top = ShapePosition.Bottom;
这些都不引起它移动
fr.RelativeVertical = RelativeVertical.Page;
这使它完美地位于顶部,但我需要在底部
我想我需要一个补偿,但是我不知道如何应用它,因为top属性对我没有任何作用。
我的页面设置如下:
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";
像这样的Addfooter:
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());
}
答案 0 :(得分:0)
请勿设置Top
的{{1}}属性,而应设置TextFrame
属性。还要将WrapFormat.DistanceTop
属性设置为WrapFormat.Style
。
另请参阅:https://forum.pdfsharp.net/viewtopic.php?p=6922#p6922
AFAIK,如果您将表格的WrapStyle.Through
属性设置为0,则不必设置框架的MarginLeft
属性。默认情况下,表格的缩进为负,因此表格中的文本对齐表格外有文字。