Inserting pagebreak after table

Hi,
I’m trying to insert a pagebreak after a table (using a new paragraph as the anchor point or location of the pagebreak), but cannot get it to work. This is what I’ve tried so far:

NodeCollection OutTables = DestDoc.GetChildNodes(NodeType.Table, true);
// get the destination table, AFTER which the paragraph will be inserted
Table DestTable = (Table) OutTables[DestTableIndex];
// insert a paragraph after the current destination table
Paragraph par = new Paragraph(DestDoc);
Node node = DestTable.ParentNode.InsertAfter(par, DestTable);
Section currentSect = (Section) par.GetAncestor(NodeType.Section);
// Get index of paragraph in the current section
int parIndex = currentSect.Body.Paragraphs.IndexOf(par);
int sectIndex = DestDoc.Sections.IndexOf(currentSect);
DestBuilder.MoveToSection(sectIndex);
DestBuilder.MoveToParagraph(parIndex, -1);
DestBuilder.InsertBreak(BreakType.PageBreak);

It seems that the paragraph is inserted in the middle of the table instead of after the table, and the pagebreak is not visible. Any ideas will be highly appreciated.
Best regards and thanks,
Michael

Hi
Thanks for your inquiry. Please try using the following code:

// Open document and create DocumentBuilder
Document doc = new Document(@"Test117\in.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
// Get Table
Table tab = doc.FirstSection.Body.Tables[0];
// Create new paragraph and insert it after table
Paragraph par = new Paragraph(doc);
tab.ParentNode.InsertAfter(par, tab);
// move documentBuilder cursor to the paragraph
builder.MoveTo(par);
// Insert page break
builder.InsertBreak(BreakType.PageBreak);
// Save output document
doc.Save(@"Test117\out.doc");

I hope this helps.
Best regards.