I am having
different problems with nested tables.
QUESTION 1:
I think that
Example 13 of chapter five has a wrong result.
Check Chap0513.pdf
and you will see that cell 0,3 is divided in two, while the table was only
inserted in cell 1,3.
QUESTION 2:
Also, example 13
uses complete(), but example 17 does not use complete(). I was the guy that
complained on deep nested tables to Paulo (Sourceforge BUG 513961), who told me
he was going to document complete(), or, at least, put it on
the examples. However, from the code of Table.java,
understand that complete() is not needed anymore, since a table is
"completed" just after it is inserted (Table.java line
580).
QUESTION 3:
The point, that I
will re-create with a quasi-minimal program, is that a deep inserted table seems
to be creating rows in its container table, instead of keeping itself inside a
cell.
Ok, here is my
program example. It names all cells that I created. When printing, however, new
rows appear between B1 and B2.
I am using
complete(), but it makes no difference.
------------------JAVA CODE - file Misbehavior.java
------------------------------------------------
import
java.awt.Point;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
public class Misbehavior
{
public static void main(String[] args)
{
System.out.println("A simple misbehavior - nested tables");
// 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("ERRO.pdf"));
// step 3: we open the document
document.open();
// step 4: we create a table and add it to the document
Table secondTable = new Table(7,7);
for(int i=0;i<7;i++) {
for(int j=0;j<7;j++) {
secondTable.addCell("A "+i+"."+j, new Point(i,j));
}
}
Table aThirdTable = new Table(5,5);
for(int i=0;i<5;i++) {
for(int j=0;j<5;j++) {
if (i==1 && j==3) {
aThirdTable.insertTable(secondTable, new Point(i,j));
} else
aThirdTable.addCell("B "+i+"."+j, new Point(i,j));
}
}
aThirdTable.complete();
Table
aTable = new Table(3,3);
for(int i=0;i<3;i++) {
for(int j=0;j<3;j++) {
if (i==1 && j==2) {
aTable.insertTable(aThirdTable, new Point(i,j));
} else
aTable.addCell("C "+i+"."+j, new Point(i,j));
}
}
aTable.complete();
for(int i=0;i<3;i++) {
for(int j=0;j<3;j++) {
if (i==1 && j==2) {
aTable.insertTable(aThirdTable, new Point(i,j));
} else
aTable.addCell("C "+i+"."+j, new Point(i,j));
}
}
aTable.complete();
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();
}
}
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}
}
-------------------------------------------------------------------------------------------------------------------------
Geraldo Xex�o
Dir. de Desenvolvimento
Trails Sistemas - (21) 2517
4099
