Hi,
I am writing a problem using iText, that use rowspan over more pages and also need to Cells fit page automatically.
but it has problem , when I try using method setCellsFitPage(true) .
The outpuf pdf file will increase size innormally.
Could you give me the solutions.
Thanks in advance.
Rady
-------------------------
import java.awt.Point;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.PdfWriter;
public class Chap0501 {
public static void main(String[] args) {
System.out.println("Chapter 5 example 1: my first table");
// step 1: creation of a document-object
Document document = new Document();
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter.getInstance(document, new FileOutputStream("Chap0501.pdf"));
// s tep 3: we open the document
document.open();
// step 4: we create a table and add it to the document
Table aTable = new Table(4,10); // 10 rows, 4 columns
aTable.setAutoFillEmptyCells(true);
aTable.setCellsFitPage(true); // problem here
for ( int row=0; row<100; row++){
aTable.addCell("row " + row, new Point(row, 3));
}
int rowIndex = 4;
int rowSpan = 96;
Cell cell = new Cell("row" + rowIndex);
cell.setRowspan(rowSpan);
aTable.addCell(cell, new Point(rowIndex,0));
document.add(aTable);
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}
}
public static void main(String[] args) {
System.out.println("Chapter 5 example 1: my first table");
// step 1: creation of a document-object
Document document = new Document();
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter.getInstance(document, new FileOutputStream("Chap0501.pdf"));
// s tep 3: we open the document
document.open();
// step 4: we create a table and add it to the document
Table aTable = new Table(4,10); // 10 rows, 4 columns
aTable.setAutoFillEmptyCells(true);
aTable.setCellsFitPage(true); // problem here
for ( int row=0; row<100; row++){
aTable.addCell("row " + row, new Point(row, 3));
}
int rowIndex = 4;
int rowSpan = 96;
Cell cell = new Cell("row" + rowIndex);
cell.setRowspan(rowSpan);
aTable.addCell(cell, new Point(rowIndex,0));
document.add(aTable);
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}
}
Yahoo! for Good
Watch the Hurricane Katrina Shelter From The Storm concert
