* @param args no arguments needed
*/
public static void main(String[] args) {
System.out.println("adding cells at a specific position");
// step 1: creation of a document-object
LwgDocument document = new LwgDocument();
try {
// step 2: creation of the writer
PdfWriter.getInstance(document,
new GfrFileOutputStream("com.lowagie.examples.objects.tables.alternatives.SpecificCells.pdf"));
// step 3: we open the document
document.open();
// step 4: we create a table and add it to the document
Table aTable;
aTable = new Table(4,4); // 4 rows, 4 columns
aTable.setAlignment(LwgElement.ALIGN_RIGHT);
aTable.addCell("2.2", new Point(2,2));
aTable.addCell("3.3", new Point(3,3));
aTable.addCell("2.1", new Point(2,1));
aTable.addCell("1.3", new Point(1,3));
document.add(aTable);
document.add(new Paragraph("converted to PdfPTable:"));
aTable.setConvert2pdfptable(true);
document.add(aTable);
document.newPage();
aTable = new Table(4,4); // 4 rows, 4 columns
aTable.setAlignment(LwgElement.ALIGN_CENTER);
aTable.addCell("2.2", new Point(2,2));
aTable.addCell("3.3", new Point(3,3));
aTable.addCell("2.1", new Point(2,1));
aTable.addCell("1.3", new Point(1,3));
aTable.addCell("5.2", new Point(5,2));
aTable.addCell("6.1", new Point(6,1));
aTable.addCell("5.0", new Point(5,0));
document.add(aTable);
document.add(new Paragraph("converted to PdfPTable:"));
aTable.setConvert2pdfptable(true);
document.add(aTable);
document.newPage();
aTable = new Table(2,2); // 2 rows, 2 columns
aTable.setAlignment(LwgElement.ALIGN_LEFT);
aTable.setAutoFillEmptyCells(true);
aTable.addCell("0.0");
aTable.addCell("0.1");
aTable.addCell("1.0");
aTable.addCell("1.1");
aTable.addColumns(2);
float[] f = {1f, 1f, 1f, 1f};
aTable.setWidths(f);
aTable.addCell("2.2", new Point(2,2));
aTable.addCell("3.3", new Point(3,3));
aTable.addCell("2.1", new Point(2,1));
aTable.addCell("1.3", new Point(1,3));
aTable.addCell("5.2", new Point(5,2));
aTable.addCell("6.1", new Point(6,1));
aTable.addCell("5.0", new Point(5,0));
document.add(aTable);
document.add(new Paragraph("converted to PdfPTable:"));
aTable.setConvert2pdfptable(true);
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();
}