title: OpenXML SDK: Count number of lines remaining in a document
body: <p>Is there a way to count the number of lines (I just need to determine the amount of space left) remaining in a page (Word File) using OpenXML and C#?</p>
  
  <p>Edit:</p>
  
  <p>My Pseudo-code for where I need to use this goes like this:</p>
  
  <ol>
  <li>Create array for table creation</li>
  <li>Open document</li>
  <li>Set table properties</li>
  <li>Cycle through the array using a for loop to create the cells and rows
  
  <blockquote>
    <p>before one loop ends I want to check how much space is left on the page</p>
  </blockquote></li>
  <li>Append the table to the document</li>
  </ol>
  
  <p>Here is the code for the loop:</p>
  
  <pre><code>for (var i = 0; i &lt;= data.GetUpperBound(0); i++)
  {
      var tr = new TableRow();
      for (var j = 0; j &lt;= data.GetUpperBound(1); j++)
      {
          var tc = new TableCell();
          tc.Append(new Paragraph(new Run(new Text(data[i, j]))));
  
          // Assume you want columns that are automatically sized.
          tc.Append(new TableCellProperties(
              new TableCellWidth { Type = TableWidthUnitValues.Auto }));
  
          tr.Append(tc);
  
      }
      table.Append(tr);
  
      //Check for remaining space here
  }
  </code></pre>