Hi
Thanks for your inquiry. You can not insert Page break into the table, so you should split your table to few separate tables and insert page breaks between these tables. For example see the following code:
// Open document
Document doc = new Document(@"Test059\in.doc");
// Create DocumentBuilder
DocumentBuilder builder = new DocumentBuilder(doc);
// Get collection of Rows from the document
NodeCollection rows = doc.GetChildNodes(NodeType.Row, true);
// Loop though rows
foreach (Row row in rows)
{
if (!row.IsFirstRow)
{
if (row.FirstCell.CellFormat.Shading.BackgroundPatternColor == Color.FromArgb(255, 255, 0, 0))
{
// Create new Paragraph and insert it after old table
Paragraph par = new Paragraph(doc);
row.ParentTable.ParentNode.InsertAfter(par, row.ParentTable);
// Create new Table
Table newTab = new Table(doc);
// Copy rows after current row into the new Table
Node currentRow = row;
while (currentRow != null)
{
if (currentRow.NextSibling != null)
{
currentRow = currentRow.NextSibling;
newTab.AppendChild(currentRow.PreviousSibling);
}
else
{
newTab.AppendChild(currentRow);
currentRow = currentRow.NextSibling;
}
}
// Insert new table into the document
par.ParentNode.InsertAfter(newTab, par);
// Insert Page brek between tables
builder.MoveTo(par);
builder.InsertBreak(BreakType.PageBreak);
}
}
}
// Save output document
doc.Save(@"Test059\out.doc");
Hope this helps.
Best regards.