import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPRow;
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 writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
PdfPTable table = new PdfPTable(2);
float[] rows = { 50f, 250f };
table.setTotalWidth(rows);
for (int k = 0; k < 200; ++k) {
table.addCell("row " + k);
table.addCell("blah " + k);
}
document.add(new Paragraph("row 150 - 200"));
table.writeSelectedRows(150, -1, 150, 820, cb);
PdfPRow row;
for (Iterator i = table.getRows().iterator(); i.hasNext();) {
row = (PdfPRow) i.next();
System.out.print(" ");
System.out.print(row.getMaxHeights());
}
document.close();
}
}
|