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

Free Support Forum - aspose.com

Keeping a table together on one page

Is it possible to tell Aspose Words to keep a table together on one page using Linq reporting engine ?
I’m starting a table near the bottom of a page, so
I’d rather have the entire table on the next page instead of being
broken over two pages (it’s not too long to all fit on one page).

Thanks

Hi Simone,


Thanks for your inquiry. Please check following article:
http://www.aspose.com/docs/display/wordsjava/Keeping+Tables+and+Rows+from+Breaking+across+Pages

Hope, this helps.

Best regards,

Hi,

i was looking for a way of doing it directly on the template and via API.
Thanks

Hi Simone,

Thanks for your inquiry. After building the report, please post-process document and apply code from here to keep tables together on one page.

Best regards,

So there is no way of doing it directly on the template file ?
thanks

Simone


Hi Simone,


Thanks for your inquiry. I am afraid, there’s no way you can achieve this using LINQ reporting engine. However, if the target Table(s) are present in template, you can try executing the same code before building report.

Best regards,

Hi Simone,


I think, there is yet another thing to try. Please see the attached TableRowsTogether.docx template. Using this template, I achieved the attached out.docx file which seems to be exactly what you want.

To achieve this behavior, I did as follows:

  1. Selected all rows in a table of the template document using the MS Word editor.
  2. At the Line and Page Breaks tab of a paragraph setting dialog, checked the Keep with Next option.
  3. Saved the template and used the reporting engine to build a report in a common way.

I used the following code to generate out.docx:
Document doc = new Document(getMyDir() + “TableRowsTogether.docx”);

ArrayList arrList = new ArrayList();
arrList.add(“Item1”);
arrList.add(“Item2”);
arrList.add(“Item3”);

ReportingEngine engine = new ReportingEngine();
engine.buildReport(doc, arrList, “items”);

doc.save(getMyDir() + “out.docx”);

Best regards,

Thank u very much, i’ll try it asap.

Simone