PdfSharpCore icon indicating copy to clipboard operation
PdfSharpCore copied to clipboard

Vertical alignment of TextFrame in Footer

Open waleedabdeen opened this issue 4 years ago • 0 comments

Hi,

I am facing an issue with placing two TextFrame in footer vertically. I have been stuck with this is for quite some times.

Here is my code.

            section.PageSetup = _document.DefaultPageSetup.Clone();
            section.PageSetup.TopMargin = "11cm";
            section.PageSetup.LeftMargin = "1.5cm";
            section.PageSetup.BottomMargin = "8cm";

            var frame1 = new TextFrame();
            frame1.RelativeVertical = RelativeVertical.Page;
            frame1.RelativeHorizontal = RelativeHorizontal.Page;
            frame1.WrapFormat.Style = WrapStyle.Through;
            frame1.WrapFormat.DistanceLeft = "2.78cm";
            frame1.WrapFormat.DistanceBottom = "1.0cm";
            frame1.Width = "2.5cm";
            frame1.Height = "1.0cm";
            frame1.LineFormat.Color = Colors.Black;            

            var frameParagraph1 = frame1.AddParagraph();
            frameParagraph1.AddText("This should be higher");
            frameParagraph1.Format.LineSpacingRule = LineSpacingRule.OnePtFive;
            
            var frame2 = new TextFrame();
            frame2.RelativeVertical = RelativeVertical.Page;
            frame2.RelativeHorizontal = RelativeHorizontal.Page;
            frame2.WrapFormat.Style = WrapStyle.Through;
            frame2.WrapFormat.DistanceLeft = "7.15cm";
            frame2.WrapFormat.DistanceBottom = "4.0cm";
            frame2.Width = "3.0cm";
            frame2.Height = "1.0cm";
            frame2.LineFormat.Color = Colors.Black;
            

            var framePragraph2 = frame2.AddParagraph();
            framePragraph2.AddText("This should be lower");

            section.Footers.Primary.Add(frame1);
            section.Footers.Primary.Add(frame2);

And here is the output

screenshot

Notes

  • I did not have any issue with the header , but only with the footer.
  • The issue does not appear when i place only one text frame in the footer.
  • I noticed that the frames are positioned based on the position of the last text frame that i add.
  • Horizontal alignment works well.

waleedabdeen avatar Apr 09 '21 21:04 waleedabdeen