We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Restrict table breaks on page columns

Hi,
I have a word document where I copy to another document with 6 columns per page.

In my document I have tables as well. I need a way to restrict tables from breaking to 2 columns.Instead move complete table to next column.

Its similar functionaly of “AllowBreakAcrossPages” but I need at column level.
Attached document for reference 58f07976-7bdb-45c3-bb43-8a8dbde4539d_Target.zip (924.5 KB)

Second page 3-4 columns

@TejKamal_Thotakuri

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

I am sorry I cant share my code but if you look at the document attached you will clearly undertand the issue.

I read document(Single text column) and append it to target document(6 columns in page) which is breaking the table to new text column.
I know this is expected behaviour but in such scenarios I want to move complete table to next textcolumn

@TejKamal_Thotakuri

Thanks for sharing the detail. In your case, we suggest you please insert the column break before the table that is in two columns to get the desired output.

Ya I can do that but there can be a scenario where it fits in first column itself right ?
Such scenarios there will be lot of empty space left.

@TejKamal_Thotakuri

Please ZIP and attach your input and expected output Word document here for our reference. We will investigate the issue and provide with you more information on it.

Please find attached on same.Docs.zip (1.8 MB)

@TejKamal_Thotakuri

Thanks for sharing the documents. Please spare us some time for the investigation of your requirement. We will get back to you soon.

@TejKamal_Thotakuri

In the Required.doc, you inserted empty paragraphs to move the table to the next column. Please note that Aspose.Words mimics the behavior of MS Word. You can achieve your requirement by using “Keep with Next” property of paragraph. Please use the following code example. Hope this helps you.

Document doc = new Document(MyDir + "Actual.doc");
 
foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
    foreach (Cell cell in table.GetChildNodes(NodeType.Cell, true))
    {
        cell.EnsureMinimum();
        foreach (Paragraph para in cell.Paragraphs)
            if (!(cell.ParentRow.IsLastRow && para.IsEndOfCell))
                para.ParagraphFormat.KeepWithNext = true;
    }
}
doc.Save(MyDir + "out.docx");