Finding tables which come across on multiple pages

Hi there,

In my attached template, 5th table was appeared on multiple pages. I want to go thru all the tables in the code and identify which tables come across on multiple pages, so that I can insert a page break before the table. I would like to do this using Aspose Words API rather than changing template.

In API how can we determine this?

Hi Srinu,

Thanks for your inquiry. I suggest you please read the article about ‘Keeping a Table from Breaking across Pages’ from here:
http://www.aspose.com/docs/display/wordsnet/Keeping+Tables+and+Rows+from+Breaking+across+Pages

Hope this helps you. You can also get the page number where table start and end. Please check following code example for your kind reference.

Aspose.Words uses our own Rendering Engine to layout documents into pages. The Aspose.Words.Layout namespace provides
classes that allow to access information such as on what page and where
on a page particular document elements are positioned, when the document
is formatted into pages. Please read about Aspose.Words.Layout Namespace from here:
http://www.aspose.com/docs/display/wordsnet/Aspose.Words.Layout+namespace


Document
doc = new Document(MyDir + “TableWrap.docx”);

DocumentBuilder builder = new DocumentBuilder(doc);

LayoutCollector collector = new LayoutCollector(doc);

foreach (Table table in doc.GetChildNodes(NodeType.Table, true))

{

if (collector.GetStartPageIndex(table.FirstRow.FirstCell.FirstParagraph) != collector.GetEndPageIndex(table.LastRow.FirstCell.LastParagraph))

{

if (table.PreviousSibling != null)

{

builder.MoveTo(table.PreviousSibling);

builder.InsertBreak(BreakType.PageBreak);

}

}

}

doc.Save(MyDir + "Out.docx");