import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
public class SplitTablePDF {
public static void main(String[] args) {
Document document = new Document(PageSize.A4, 10, 10, 10, 10);
try {
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SplitTablePDF.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
PdfPTable table = new PdfPTable(10);
for (int i = 1; i <= 100; ++i) {
table.addCell(Integer.toString(i));
}
table.setTotalWidth(800);
table.writeSelectedRows(0, 5, 0, -1, 50, 650, cb);
document.newPage();
table.writeSelectedRows(5, -1, 0, -1, 50, 650, cb);
} catch (Exception de) {
de.printStackTrace();
}
document.close();
}
}
|