Search in sources :

Example 21 with Table

use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.

the class C05E03_CellAlignment method createPdf.

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(UnitValue.createPercentArray(new float[] { 2, 1, 1 }));
    table.setWidth(UnitValue.createPercentValue(80));
    table.setHorizontalAlignment(HorizontalAlignment.CENTER);
    table.setTextAlignment(TextAlignment.CENTER);
    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")).setTextAlignment(TextAlignment.RIGHT));
    table.addCell("row 1; cell 1");
    table.addCell("row 1; cell 2");
    table.addCell("row 2; cell 1");
    table.addCell("row 2; cell 2");
    Cell cell = new Cell().add(new Paragraph("Left").setTextAlignment(TextAlignment.LEFT)).add(new Paragraph("Center")).add(new Paragraph("Right").setTextAlignment(TextAlignment.RIGHT));
    table.addCell(cell);
    cell = new Cell().add(new Paragraph("Middle")).setVerticalAlignment(VerticalAlignment.MIDDLE);
    table.addCell(cell);
    cell = new Cell().add(new Paragraph("Bottom")).setVerticalAlignment(VerticalAlignment.BOTTOM);
    table.addCell(cell);
    document.add(table);
    document.close();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) Cell(com.itextpdf.layout.element.Cell) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph)

Example 22 with Table

use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.

the class C05E02_ColumnWidths5 method createPdf.

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[] { 2, 1, 1 });
    table.setWidth(UnitValue.createPercentValue(80));
    table.setHorizontalAlignment(HorizontalAlignment.CENTER);
    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();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) Cell(com.itextpdf.layout.element.Cell) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph)

Example 23 with Table

use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.

the class C05E05_CellPaddingMargin method createPdf.

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(UnitValue.createPercentArray(new float[] { 2, 1, 1 }));
    table.setBackgroundColor(ColorConstants.ORANGE);
    table.setWidth(UnitValue.createPercentValue(80));
    table.setHorizontalAlignment(HorizontalAlignment.CENTER);
    table.addCell(new MarginCell(1, 3).add(new Paragraph("Cell with colspan 3")).setPadding(10).setMargin(5).setBackgroundColor(ColorConstants.GREEN));
    table.addCell(new MarginCell(2, 1).add(new Paragraph("Cell with rowspan 2")).setMarginTop(5).setMarginBottom(5).setPaddingLeft(30).setFontColor(ColorConstants.WHITE).setBackgroundColor(ColorConstants.BLUE));
    table.addCell(new MarginCell().add(new Paragraph("row 1; cell 1")).setFontColor(ColorConstants.WHITE).setBackgroundColor(ColorConstants.RED));
    table.addCell(new MarginCell().add(new Paragraph("row 1; cell 2")));
    table.addCell(new MarginCell().add(new Paragraph("row 2; cell 1")).setMargin(10).setFontColor(ColorConstants.WHITE).setBackgroundColor(ColorConstants.RED));
    table.addCell(new MarginCell().add(new Paragraph("row 2; cell 2")).setPadding(10).setFontColor(ColorConstants.WHITE).setBackgroundColor(ColorConstants.RED));
    document.add(table);
    document.close();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph)

Example 24 with Table

use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.

the class C05E06_CellBorders2 method createPdf.

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(UnitValue.createPercentArray(new float[] { 2, 1, 1 }));
    table.setBorder(new SolidBorder(3)).setWidth(UnitValue.createPercentValue(80)).setHorizontalAlignment(HorizontalAlignment.CENTER).setTextAlignment(TextAlignment.CENTER);
    table.addCell(new Cell(1, 3).add(new Paragraph("Cell with colspan 3")).setVerticalAlignment(VerticalAlignment.MIDDLE).setBorder(Border.NO_BORDER));
    table.addCell(new Cell(2, 1).add(new Paragraph("Cell with rowspan 2")).setVerticalAlignment(VerticalAlignment.MIDDLE).setBorder(Border.NO_BORDER));
    table.addCell(new Cell().add(new Paragraph("row 1; cell 1")));
    table.addCell(new Cell().add(new Paragraph("row 1; cell 2")));
    table.addCell(new Cell().add(new Paragraph("row 2; cell 1")));
    table.addCell(new Cell().add(new Paragraph("row 2; cell 2")));
    document.add(table);
    document.close();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) Cell(com.itextpdf.layout.element.Cell) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) SolidBorder(com.itextpdf.layout.borders.SolidBorder) Paragraph(com.itextpdf.layout.element.Paragraph)

Example 25 with Table

use of com.itextpdf.layout.element.Table in project i7js-highlevel by itext.

the class C05E06_CellBorders4 method createPdf.

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(UnitValue.createPercentArray(new float[] { 2, 1, 1 })).setWidth(UnitValue.createPercentValue(80)).setHorizontalAlignment(HorizontalAlignment.CENTER).setTextAlignment(TextAlignment.CENTER);
    Cell cell = new RoundedCornersCell(1, 3).add(new Paragraph("Cell with colspan 3"));
    table.addCell(cell);
    cell = new RoundedCornersCell(2, 1).add(new Paragraph("Cell with rowspan 2"));
    table.addCell(cell);
    cell = new RoundedCornersCell().add(new Paragraph("row 1; cell 1"));
    table.addCell(cell);
    cell = new RoundedCornersCell().add(new Paragraph("row 1; cell 2"));
    table.addCell(cell);
    cell = new RoundedCornersCell().add(new Paragraph("row 2; cell 1"));
    table.addCell(cell);
    cell = new RoundedCornersCell().add(new Paragraph("row 2; cell 2"));
    table.addCell(cell);
    table.setNextRenderer(new RoundedCornersTableRenderer(table));
    document.add(table);
    document.close();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) Cell(com.itextpdf.layout.element.Cell) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph)

Aggregations

Table (com.itextpdf.layout.element.Table)37 Cell (com.itextpdf.layout.element.Cell)29 PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)25 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)25 Document (com.itextpdf.layout.Document)25 Paragraph (com.itextpdf.layout.element.Paragraph)22 CsvTo2DList (com.itextpdf.highlevel.util.CsvTo2DList)7 List (java.util.List)7 SolidBorder (com.itextpdf.layout.borders.SolidBorder)3 DashedBorder (com.itextpdf.layout.borders.DashedBorder)2 DottedBorder (com.itextpdf.layout.borders.DottedBorder)2 Image (com.itextpdf.layout.element.Image)2 IOException (java.io.IOException)2 PdfFont (com.itextpdf.kernel.font.PdfFont)1 Rectangle (com.itextpdf.kernel.geom.Rectangle)1 PdfDocumentInfo (com.itextpdf.kernel.pdf.PdfDocumentInfo)1 PdfCanvas (com.itextpdf.kernel.pdf.canvas.PdfCanvas)1 Canvas (com.itextpdf.layout.Canvas)1 Style (com.itextpdf.layout.Style)1 SolidBorder (com.itextpdf.layout.border.SolidBorder)1