Search in sources :

Example 6 with Cell

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

the class C05E02_ColumnWidths4 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.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 7 with Cell

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

the class C05E05_CellPadding 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 Cell(1, 3).add(new Paragraph("Cell with colspan 3")).setPadding(10).setBackgroundColor(ColorConstants.GREEN));
    table.addCell(new Cell(2, 1).add(new Paragraph("Cell with rowspan 2")).setPaddingLeft(30).setFontColor(ColorConstants.WHITE).setBackgroundColor(ColorConstants.BLUE));
    table.addCell(new Cell().add(new Paragraph("row 1; cell 1")).setFontColor(ColorConstants.WHITE).setBackgroundColor(ColorConstants.RED));
    table.addCell(new Cell().add(new Paragraph("row 1; cell 2")));
    table.addCell(new Cell().add(new Paragraph("row 2; cell 1")).setFontColor(ColorConstants.WHITE).setBackgroundColor(ColorConstants.RED));
    table.addCell(new Cell().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) Cell(com.itextpdf.layout.element.Cell) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph)

Example 8 with Cell

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

the class C05E06_CellBorders1 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)).setHorizontalAlignment(HorizontalAlignment.CENTER).setTextAlignment(TextAlignment.CENTER);
    table.addCell(new Cell(1, 3).add(new Paragraph("Cell with colspan 3")).setVerticalAlignment(VerticalAlignment.MIDDLE).setBorder(new DashedBorder(0.5f)));
    table.addCell(new Cell(2, 1).add(new Paragraph("Cell with rowspan 2")).setVerticalAlignment(VerticalAlignment.MIDDLE).setBorderBottom(new DottedBorder(0.5f)).setBorderLeft(new DottedBorder(0.5f)));
    table.addCell(new Cell().add(new Paragraph("row 1; cell 1")).setBorder(new DottedBorder(ColorConstants.ORANGE, 0.5f)));
    table.addCell(new Cell().add(new Paragraph("row 1; cell 2")));
    table.addCell(new Cell().add(new Paragraph("row 2; cell 1")).setBorderBottom(new SolidBorder(2)));
    table.addCell(new Cell().add(new Paragraph("row 2; cell 2")).setBorderBottom(new SolidBorder(2)));
    document.add(table);
    document.close();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) DashedBorder(com.itextpdf.layout.borders.DashedBorder) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Document(com.itextpdf.layout.Document) DottedBorder(com.itextpdf.layout.borders.DottedBorder) Cell(com.itextpdf.layout.element.Cell) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph) SolidBorder(com.itextpdf.layout.borders.SolidBorder)

Example 9 with Cell

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

the class C05E06_CellBorders3 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)).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);
    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 10 with Cell

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

the class C05E07_NestedTable 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[] { 1, 1 }).setWidth(UnitValue.createPercentValue(80)).setHorizontalAlignment(HorizontalAlignment.CENTER);
    table.addCell(new Cell(1, 2).add(new Paragraph("Cell with colspan 2")));
    table.addCell(new Cell().add(new Paragraph("Cell with rowspan 1")));
    Table inner = new Table(new float[] { 1, 1 });
    inner.addCell("row 1; cell 1");
    inner.addCell("row 1; cell 2");
    inner.addCell("row 2; cell 1");
    inner.addCell("row 2; cell 2");
    table.addCell(inner);
    document.add(table);
    table = new Table(new float[] { 1, 1 }).setMarginTop(10).setWidth(UnitValue.createPercentValue(80)).setHorizontalAlignment(HorizontalAlignment.CENTER);
    table.addCell(new Cell(1, 2).add(new Paragraph("Cell with colspan 2")));
    table.addCell(new Cell().add(new Paragraph("Cell with rowspan 1")));
    inner = new Table(new float[] { 1, 1 });
    inner.addCell("row 1; cell 1");
    inner.addCell("row 1; cell 2");
    inner.addCell("row 2; cell 1");
    inner.addCell("row 2; cell 2");
    table.addCell(new Cell().add(inner).setPadding(0));
    document.add(table);
    table = new Table(new float[] { 1, 1 }).setMarginTop(10).setWidth(UnitValue.createPercentValue(80)).setHorizontalAlignment(HorizontalAlignment.CENTER);
    table.addCell(new Cell(1, 2).add(new Paragraph("Cell with colspan 2")));
    table.addCell(new Cell().add(new Paragraph("Cell with rowspan 1")));
    inner = new Table(new float[] { 1, 1 }).setWidth(UnitValue.createPercentValue(100));
    inner.addCell("row 1; cell 1");
    inner.addCell("row 1; cell 2");
    inner.addCell("row 2; cell 1");
    inner.addCell("row 2; cell 2");
    table.addCell(new Cell().add(inner).setPadding(0));
    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

Cell (com.itextpdf.layout.element.Cell)34 Table (com.itextpdf.layout.element.Table)29 PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)21 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)21 Document (com.itextpdf.layout.Document)21 Paragraph (com.itextpdf.layout.element.Paragraph)21 CsvTo2DList (com.itextpdf.highlevel.util.CsvTo2DList)6 List (java.util.List)6 Image (com.itextpdf.layout.element.Image)4 DottedBorder (com.itextpdf.layout.borders.DottedBorder)3 SolidBorder (com.itextpdf.layout.borders.SolidBorder)3 IOException (java.io.IOException)3 DashedBorder (com.itextpdf.layout.borders.DashedBorder)2 File (java.io.File)2 BarcodeEAN (com.itextpdf.barcodes.BarcodeEAN)1 ImageData (com.itextpdf.io.image.ImageData)1 PdfFont (com.itextpdf.kernel.font.PdfFont)1 Style (com.itextpdf.layout.Style)1 AreaBreak (com.itextpdf.layout.element.AreaBreak)1 Link (com.itextpdf.layout.element.Link)1