Free Support Forum - aspose.com

Question on how to move to a new page if the content is too long

<span style=“font-size: 12pt; font-family: “Arial Unicode MS”;”>Hi,

I want to make the whole table as attached in the word document to move to a new page if the above content is too long. So how can I make such function?

Regards,
Ken Wan

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I think you can try using “Keep with Next” option of paragraphs. For example, please see the following code:

// Create empty docuemnt and DocumentBuilder

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// Insert few paragraphs at the beggining of the document

for (int i = 0; i < 20; i++)

builder.Writeln("This is paragraphs for testing");

// Enable "Keep with Next option"

builder.ParagraphFormat.KeepWithNext = true;

// Build some table

builder.CellFormat.Width = 200;

builder.CellFormat.Borders.LineStyle = LineStyle.Single;

builder.CellFormat.Borders.Color = Color.Black;

for (int i = 0; i < 30; i++)

{

for (int j = 0; j < 2; j++)

{

builder.InsertCell();

builder.Write("This is test content of the table");

}

builder.EndRow();

}

builder.EndTable();

// Save output document

doc.Save(@"Test001\out.doc");

I also attached the output document.

Hope this helps.

Best regards.

Hi,

Is there any method can solve it in word template only without any coding?

Regards,
Ken Wan

Hi,

Thank you for your solution before. But I afraid I can’t apply the following solution to my system. I’m using a general function to mail merge the data into mail merge field. I don’t have a specific function to write content using document builder. So would you mind to provide another solution, to configurate in word template?

Regards,
Ken Wan

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. You can do the same changes in your template. Just select whole table, and set “Keep with next” option for each paragraph in this table.

If you need, I can help you to change the template. If so, please attach your template here.

Best regards.

Hi,

I have tried and failed. Would you mind to help me to work on it.

Thank you for your kindly help.

Regards,
Ken Wan

Hi <?xml:namespace prefix = st1 ns = "urn:schemas:contacts" />Ken,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I sent the modified template to your e-mail. I also disabled “Allow break across pages option”. Hope this helps.

Best regards.