bug: Java iText 5.5.9 doesn't correctly work with MayNotBreak for 2 grouped rows

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

bug: Java iText 5.5.9 doesn't correctly work with MayNotBreak for 2 grouped rows

This post was updated on .
I am trying to work with MayNotBreak to keep group of rows in a table together.
I noticed when upgrading from 5.5.1 to 5.5.9, the behavior of MayNotBreak changed, in what I think is an incorrect way.

In my code, I want to group 2 sets of rows together, such that they will never be on separate pages.

Example that my PDF follows. Rows N and N+1 should stick together if N is even (0,2,etc...).
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;

public class split_at_row {
	public static final String DEST = "split_at_row.pdf";

	public static void main(String[] args) throws IOException,
			DocumentException {
		new split_at_row().createPdf(DEST);

	public void createPdf(String dest) throws IOException, DocumentException {
		PdfPTable table = new PdfPTable(1);

			PdfPCell cell = new PdfPCell(new Phrase("-1"));

		final int n = 2;

		for (int i = 0; i < 30; i++) {
			PdfPCell cell;
			if (i % n != 0) {
				cell = new PdfPCell(new Phrase("Group"));
			} else {
				cell = new PdfPCell(new Phrase(Integer.toString(i)));

		Document document = new Document(new Rectangle(612, 242));
		PdfWriter.getInstance(document, new FileOutputStream(dest));


		for (int i = 0; i < 12; i++) {
			if (i % n != (n - 1)) {



On 5.5.1, the first page ends with "6, Group" which to me seems correct.
Starting with 5.5.6, it now ends with "6, Group, 8" splitting 8 and its grouped row apart which is not what I want.

It seems the cause of the difference is because of this commit: 2cb5efc9b6df33420073541e8010977974c9a2f1

Can someone confirm this and that I am not mis-understanding the MayNotBreak option?