Dynamic width for the outer table of nested tables based on page break

Hello Aspose forum,

We are using full Aspose.Total license.

Query: We have a nested table with outer table having two columns with 33% and 66% width. The inside table in the 2nd column is dynamic in nature. We want the outer table columns to modify to 0% and 100% width respectively once the dynamic table finishes rendering content in first page and moves onto the next page.

aspose query.docx (28.9 KB)

In the above aspose query document doc, we can see that its having nested tables. The first column contains generic table and a chart and second column contains 2 dynamic tables. What we want to achieve is that once the page breaks from second page the outer table’s 2nd column must occupy the 100 percent width of the page since we dont want to waste the empty space in second page. i.e from the row containing “Deferred gold silver” we want that table entries to occupy 100 % width. Could you please let us know if there is a way to achieve this via Aspose.Words. We also want this to be achieved in pdf too. We usually generate a doc from Aspose.words and then save it as pdf for the pdf version.

@sbaskar1 I am afraid it is not possible to implement this using nested tables. However, in your case you can use section with two columns. In this case it is possible to determine where the table flows to the next page and split the table. Please see the modified document: in.docx (30.7 KB)
Here is the code to split the table and put the second part of the table into the section with one column:

Document doc = new Document(@"C:\Temp\in.docx");
LayoutCollector collector = new LayoutCollector(doc);

// Get number of pages in the document.
int pages = doc.PageCount;
if (pages > 1)
    Table table = null;
    // Search the table that break spans the second page.
    foreach(Table t in doc.FirstSection.Body.Tables)
        if (collector.GetStartPageIndex(t) != collector.GetEndPageIndex(t))
            table = t;

    if (table != null)
        // Create a section with one column to move the part of table that goes to the next page.
        Section sect = new Section(doc);

        // Copy all nodes after the table into the next section.
        while (table.NextSibling != null)

        // Clone the original table.
        Table nextPageTable = (Table)table.Clone(false);

        // Copy all rows that goes to the next page.
        int rowIndex = 0;
        int pageIndex = collector.GetStartPageIndex(table);
        foreach (Row r in table.Rows)
            if (collector.GetStartPageIndex(r) > pageIndex)
                rowIndex = table.IndexOf(r);

        while (table.Rows.Count > rowIndex)



Here are output document: out.docx (25.4 KB)