import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
public class SplitRowsPDF {
public static void main(String[] args) {
Document document1 = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
try {
PdfWriter.getInstance(document1, new FileOutputStream("SplitRowsPDF.pdf"));
document1.open();
String text = "Text Text Text Text Text Text Text Text Text";
PdfPTable table = new PdfPTable(2);
PdfPCell largeCell;
Phrase phrase;
for (int i = 0; i < 10; i++) {
phrase = new Phrase(text);
for (int j = 0; j < i; j++) {
phrase.add(new Phrase(text));
}
if (i == 7)
phrase = new Phrase(text);
table.addCell(String.valueOf(i));
largeCell = new PdfPCell(phrase);
table.addCell(largeCell);
}
document1.add(table);
table.setSplitLate(true);
} catch (Exception de) {
de.printStackTrace();
}
document1.close();
}
}
itext.zip( 1,748 k)