title: MigraDoc: Align text or a table at the bottom of the page above the footer
body: <p>I am using MigraDoc to generate a PDF.  I want to align some content to the bottom of the last page.  This is boilerplate disclaimer information that my company always includes in these types of documents.  The goal is to keep the content altogether and always have it appear just above the footer on the last page.  If there isn't room on the last page of actual content to keep it together, there should be a page break and the boilerplate content will be on a page by itself.  </p>
  
  <p>I would like to do this without measuring the height of the content.</p>
  
  <p>I get the impression that I can use TextFrame to assist with this in some way, but I can't find any documentation on it.  The questions and examples I've found online refer to being able to "absolutely position" the TextFrame, but none of the examples seem to do that, exactly. </p>
  
  <p>As a starting point, I am trying to position a paragraph of text in the way I described on an otherwise blank page.  Here's my latest experiment:</p>
  
  <pre><code>    static void AddBoilerPlate(Section section) {
          var sectionWidth = PdfSharp.PageSizeConverter.ToSize(PageSize.Letter).Width - section.Document.DefaultPageSetup.LeftMargin.Point -
              section.Document.DefaultPageSetup.RightMargin.Point;
  
          section.AddPageBreak();
          var frame = section.AddTextFrame();
          frame.RelativeVertical = RelativeVertical.Page;
          frame.Width = sectionWidth;
          frame.Top = ShapePosition.Bottom;
          frame.AddParagraph(DisclaimerText);
      }
  </code></pre>
  
  <p>The text starts just above the footer (the blue line in this screenshot) and then runs over the footer:</p>
  
  <p><a href="https://i.stack.imgur.com/9A14O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9A14O.png" alt="enter image description here"></a></p>
  
  <p>Once I get a paragraph of text aligned, then I think I will be able to use a table with one column and one row instead, and then put all of my content in there.</p>
  
  <p>Update: here is a screenshot showing my goal (faked using a page break and SpaceBefore):</p>
  
  <p><a href="https://i.stack.imgur.com/qJzwZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qJzwZ.png" alt="enter image description here"></a></p>
  
  <p>Update: here are some related articles that don't quite get me where I'm trying to go:</p>
  
  <ul>
  <li>Centering a table on a page using a TextFrame: <a href="http://forum.pdfsharp.net/viewtopic.php?p=753#p753" rel="nofollow noreferrer">http://forum.pdfsharp.net/viewtopic.php?p=753#p753</a></li>
  <li>Seems to answer the same question, but doesn't provide information about how to absolutely position the TextFrame: <a href="http://forum.pdfsharp.com/viewtopic.php?f=2&amp;t=587" rel="nofollow noreferrer">http://forum.pdfsharp.com/viewtopic.php?f=2&amp;t=587</a></li>
  <li>Keeping table together on a page ("in one piece").  This will be useful once I figure out the issue with aligning relative to the bottom of the page: <a href="https://stackoverflow.com/questions/1104227/keep-table-in-one-piece-migradoc-pdfsharp#">Keep table in one piece MigraDoc / PDFsharp</a></li>
  </ul>
  
  <p>Update: Note that adding a height to the TextFrame does make the text align the way I need it to. It's not ideal, because I would rather not hard-code the height.  But it does produce the desired effect:</p>
  
  <pre><code>    static void AddBoilerPlate(Section section) {
          var sectionWidth = PdfSharp.PageSizeConverter.ToSize(PageSize.Letter).Width - section.Document.DefaultPageSetup.LeftMargin.Point -
              section.Document.DefaultPageSetup.RightMargin.Point;
  
          section.AddPageBreak();
          var frame = section.AddTextFrame();
          frame.RelativeVertical = RelativeVertical.Page;
          **frame.Height = new Unit(75, UnitType.Millimeter);**
          frame.Width = sectionWidth;
          frame.Top = ShapePosition.Bottom;
          frame.AddParagraph(DisclaimerText);
      }
  </code></pre>
  
  <p>Update: Note, though, that setting the TextFrame height doesn't resolve the ultimate issue.  Content added before the boilerplate should push the boilerplate to the next page if there isn't enough space for it, and that's not happening.</p>