with setAllowBreakAcrossPages set to false Aspose will truncate the content of rows to a single page. This happens both for Word and PDF. Test code and output document are attached. I’m using Aspose 11.3
@Test
public void testLargeRow() throws Exception
{
DocumentBuilder docBuilder = new DocumentBuilder();
//begin table
Table table = docBuilder.startTable();
docBuilder.getRowFormat().setAllowBreakAcrossPages( false);
// The first cell
docBuilder.insertCell();
docBuilder.write("Cell 1, 1");
// The second cell
docBuilder.insertCell();
for ( int i = 0; i < 100; ++i)
{
docBuilder.writeln( "Row " + i + " out of 100");
}
// End the first row
docBuilder.endRow();
table.setAllowAutoFit( true);
// end table
docBuilder.endTable();
String docpath = new File( getBaseFolder(), "testLargeRow.doc").getAbsolutePath();
System.out.println( "Writing " + docpath + "…");
docBuilder.getDocument().save(docpath);
}
Thanks for your request. As Aspose.Word mimics MS Word features as closest as possible, so truncating a row, while contents are greater than a page size and AllowBreakAcrossPages property set to false, is expected behavior of MS Word. Please find attached a sample MS word document for reference.
Please feel free to contact us for any further assistance.
Thanks Tilal. Indeed this is Word behavior. But can this be altered, at least when saving as PDF so that the setting is ignored for rows that are larger than 1 page?
Thanks for your understanding. Unfortunately, currently Aspose.Words does not have any functionality to ignore AllowBreakAcrossPage setting. However, I have created a new feature request in our issue tracking system, WORDSNET-6773. You will be notified via this forum thread once this feature gets available.
Moreover, will keeping table break across the page serve the purpose? Please check following article for any help. https://docs.aspose.com/words/net/working-with-columns-and-rows/
Please feel free to contact us for any further assistance.
Best Regards,
I’m a bit confused with your request. If you want Aspose.Words to ignore not allowing rows to break across pages then you should just disable this setting (i.e set AllowBreakAcrossPages to true). Is there any reason you cannot perform this task before converting to PDF?
So if a row is only two to three lines long and it happens to be split across the page then is should be truncated (AllowBreak = false), however if in the same situation the row has so many lines that it would go not only onto the next page, but the page after that then it should be allowed to flow over (AllowBreak = true)? Please clarify that this is correct just so we can be sure we both have the same idea.
In any case, this request sounds quite tricky, it would involve ignoring the default behavior of the table settings and implementing some custom logic, while at the same time probably requiring refactoring of the rendering engine. I’m afraid because of these reasons, it is most likely the issue will be postponed or closed without fix.
Instead, could you clarify why exactly you need this feature? Why can’t the smaller rows have this setting enabled so there would be no need to distinguish between the two types. Perhaps there is another way to achieve what you are looking for.
Likewise, would a work around suffice for you? For example, if you could detect any large rows and enable this setting.
>>> In any case, this request sounds quite tricky, it
would involve ignoring the default behavior of the table settings and
implementing some custom log
Indeed and I realize this would not be something a generic purpose library such Aspose should do.
>>> Why can’t the smaller rows have this setting
enabled so there would be no need to distinguish between the two types.
Perhaps there is another way to achieve what you are looking for.
What I need here is a “smart” behavior which word does not support: split those rows that cannot fit a page and keep together the other ones.
>>> For example, if you could detect any large rows and enable this setting.
Yes. it would be nice to have this provided by the library as a tri-state value for the “setAllowPageBreak” method, but if we can achieve it in our code its fine.
- true - as is now
- false - as is now
- smart - the behavior described above and achieved by evaluating the row’s height when rendering it ( or after?) and deciding if it does fit a page in which case the “allow break across pages” is enabled otherwise is disabled.
Thanks for the clarification. I’m afraid after further thought it seems it would be impossible to implement this behavior using a work around. Instead you will need to wait for some sort of proper implementation. As we have described previously due to the nature of this feature it might be postponed for quite a while or may not be implemented at all.
Please let us know if we can help with anything else.
I’m afraid not as a work around. The best work around that could be offered would find what page the row starts on and ends on and which then makes a decision on what rows to enable that setting for. However this doesn’t sound like it will solve your goal.
Therefore, I’m afraid you will need to wait for the proper implementation (the issue linked to this thread).
we are also interested in this feature. In my words: If the content of a row (due to large text) is cut then AllowBreak should be true. In all other cases i want to use AllowBreak = false for a smarter look of table.
Thanks
for your inquiry. Yes, your understanding is correct about this feature. Row contents larger than a page size truncate while setting false AllowBreakAcrossPages property of RowFormat class. This is the expected behavior of MS Word and Aspose.Words. This new feature will ignore this property while row contents are larger than a page size.
I
regret to share with you that the implementation of WORDSNET-6773 has
been postponed. We will inform you as soon as there are
any further developments.