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#?
Edit:
My Pseudo-code for where I need to use this goes like this:
- Create array for table creation
- Open document
- Set table properties
- Cycle through the array using a for loop to create the cells and rows
before one loop ends I want to check how much space is left on the page
- Append the table to the document
Here is the code for the loop:
for (var i = 0; i <= data.GetUpperBound(0); i++)
{
var tr = new TableRow();
for (var j = 0; j <= 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
}