Is there any way of checking if a Paragraph fits in a table with fixed width that contains a cell with a fixed height ?

In my example below I want to split the first table to the next page .
Or a page in the end of the whole document;

I'm would really appreciate som leads on this.

Regards

Janne Berg

Example :


import com.lowagie.text.Document; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; 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;

/**
 *
 * @author janne.berg
 */
public class TableTest {

    /** Creates a new instance of TableTest */
    public TableTest() {

        // step1
        Document document = new Document(PageSize.A4, 10, 10, 10, 10);
        try {
            PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(
                    "Table.pdf"));
            document.open();


PdfPTable table = new PdfPTable(2); String alotOfText = ""; PdfPCell cell = new PdfPCell(); PdfPCell cell2 = new PdfPCell(); cell.setFixedHeight(100f); cell2.setFixedHeight(100f); for(int i = 0 ; i < 500;i++){ alotOfText += "Lorem ipsum dolor sit amet, ...."; } cell.addElement(new Paragraph(alotOfText)); cell2.addElement(new Paragraph(alotOfText)); table.addCell(cell); table.addCell(cell2); table.setWidthPercentage(100);

            document.add(table);
            document.add(getTable());
        } catch (Exception de) {
            de.printStackTrace();
        }
        // step5
        document.close();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new TableTest();
    }
    private  PdfPTable getTable(){
        PdfPTable table = new PdfPTable(6);
        table.setSpacingBefore(20f);

        table.setSpacingAfter(20f);
        for(int i = 0 ;i < 18 ;i++){
            table.addCell(i+"");
        }
        table.setWidthPercentage(100);
        return table;
    }
}







-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to