Hello,

I'm having some problems with table splitting and ListItems. Most of
the time the last item is repeated and the end of the page as you can
see in the attached PDF file. In my case, the text "hello number 9" in
first page is repeated in second page.  The same happens in the last
page with "hello number 11" and the one that seems correct to me is
the transition from the page 3 to page 4.

Is this a bug or am I doing something wrong?

Thank you.
-- 
Filipe Sousa
package pt.ipb.cdev.pdf;

import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
import java.io.FileOutputStream;

public class Main {
    private static final Font DEFAULT_FONT = new Font(Font.HELVETICA, 8);

    public static void main(String[] args) {
        Document doc = new Document();
        try {
            PdfWriter.getInstance(doc, new FileOutputStream("/home/fsousa/test.pdf"));
            doc.open();

            for (int j = 0; j < 20; j++) {
                List list = new List(true);
                for (int i = 0; i < 11; i++) {
                    ListItem item = new ListItem(DEFAULT_FONT.getSize(), "hello number " + (i+1), DEFAULT_FONT);
                    list.add(item);
                }

                PdfPCell cell = new PdfPCell();
                cell.addElement(list);

                PdfPTable table = new PdfPTable(1);
                table.setSplitLate(false);
                table.setSpacingAfter(10);
                table.setHeaderRows(1);
                table.addCell(new Phrase(DEFAULT_FONT.getSize(), "Numbers " + j, DEFAULT_FONT));
                table.addCell(cell);

                doc.add(table);
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            doc.close();
        }
    }
}

Attachment: test.pdf
Description: Adobe PDF document

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to