import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
public class MainClass {
public static void main(String[] args) throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
PdfPTable table = new PdfPTable(2);
table.setWidthPercentage(100);
table.setHeaderRows(1);
PdfPCell h1 = new PdfPCell(new Paragraph("Header 1"));
h1.setGrayFill(0.7f);
table.addCell(h1);
PdfPCell h2 = new PdfPCell(new Paragraph("Header 2"));
h2.setGrayFill(0.7f);
table.addCell(h2);
PdfPCell cell;
for (int row = 1; row <= 2000; row++) {
document.add(table);
table.deleteBodyRows();
table.setSkipFirstHeader(true);
cell = new PdfPCell(new Paragraph(String.valueOf(row)));
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Quick brown fox jumps over the lazy dog."));
table.addCell(cell);
}
document.add(table);
document.close();
}
}
|