package com.itextpdf.highlevel.chapter05; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.layout.Document; import com.itextpdf.layout.element.Cell; import com.itextpdf.layout.element.Paragraph; import com.itextpdf.layout.element.Table; import java.io.File; import java.io.IOException; /** * @author Bruno Lowagie (iText Software) */ public class C05E02_ColumnWidths1 { public static final String DEST = "results/chapter05/column_widths1.pdf"; public static void main(String args[]) throws IOException { File file = new File(DEST); file.getParentFile().mkdirs(); new C05E02_ColumnWidths1().createPdf(DEST); } public void createPdf(String dest) throws IOException { //Initialize PDF document PdfDocument pdf = new PdfDocument(new PdfWriter(dest)); // Initialize document Document document = new Document(pdf); Table table = new Table(new float[]{200, 100, 100}); table.addCell(new Cell(1, 3).add(new Paragraph("Cell with colspan 3"))); table.addCell(new Cell(2, 1).add(new Paragraph("Cell with rowspan 2"))); table.addCell("row 1; cell 1"); table.addCell("row 1; cell 2"); table.addCell("row 2; cell 1"); table.addCell("row 2; cell 2"); document.add(table); document.close(); } }