Search in sources :

Example 1 with Cell

use of com.itextpdf.layout.element.Cell in project betca-tpv-spring by miw-upm.

the class PdfTicketBuilder method tableColspanRight.

public PdfTicketBuilder tableColspanRight(String value) {
    Cell cell = new Cell(1, this.getTable().getNumberOfColumns());
    cell.setTextAlignment(TextAlignment.RIGHT).setBold().setFontSize(TERMIC_FONT_SIZE_EMPHASIZEDD);
    cell.add(value);
    this.getTable().addCell(cell);
    this.getDocument().add(this.getTable());
    return this;
}
Also used : Cell(com.itextpdf.layout.element.Cell)

Example 2 with Cell

use of com.itextpdf.layout.element.Cell in project betca-tpv-spring by miw-upm.

the class PdfTag24Builder method build.

public Optional<byte[]> build() {
    while (tag24 % 3 != 0) {
        Cell cell = new Cell();
        cell.setBorder(Border.NO_BORDER);
        this.getTable().addCell(cell);
        this.getDocument().add(this.getTable());
        tag24++;
    }
    this.getDocument().close();
    try {
        return Optional.of(Files.readAllBytes(new File(this.getFullPath()).toPath()));
    } catch (IOException ioe) {
        Logger.getLogger(this.getClass()).error("IO: " + ioe);
    }
    return Optional.empty();
}
Also used : IOException(java.io.IOException) Cell(com.itextpdf.layout.element.Cell) File(java.io.File)

Example 3 with Cell

use of com.itextpdf.layout.element.Cell in project betca-tpv-core by miw-upm.

the class PdfTableBuilder method tableColspanRight.

public PdfTableBuilder tableColspanRight(String value) {
    Cell cell = new Cell(1, this.table.getNumberOfColumns());
    cell.setTextAlignment(TextAlignment.RIGHT).setBold().setFontSize(FONT_SIZE_EMPHASIZED);
    cell.add(value);
    this.table.addCell(cell);
    return this;
}
Also used : Cell(com.itextpdf.layout.element.Cell)

Example 4 with Cell

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

the class C05E12_JekyllHydeTableV5 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, PageSize.A4.rotate());
    Table table = new Table(UnitValue.createPercentArray(new float[] { 3, 32 }));
    table.setWidth(UnitValue.createPercentValue(100));
    List<List<String>> resultSet = CsvTo2DList.convert(SRC, "|");
    resultSet.remove(0);
    table.addHeaderCell("imdb").addHeaderCell("Information about the movie");
    Cell cell;
    for (List<String> record : resultSet) {
        table.addCell(record.get(0));
        cell = new Cell().add(new Paragraph(record.get(1))).add(new Paragraph(record.get(2))).add(new Paragraph(record.get(3))).add(new Paragraph(record.get(4))).add(new Paragraph(record.get(5)));
        cell.setKeepTogether(true);
        table.addCell(cell);
    }
    document.add(table);
    document.close();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) CsvTo2DList(com.itextpdf.highlevel.util.CsvTo2DList) List(java.util.List) 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 5 with Cell

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

the class C05E14_JekyllHydeTableV7 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, PageSize.A4.rotate());
    Table table = new Table(UnitValue.createPercentArray(new float[] { 3, 2, 14, 9, 4, 3 }));
    table.setWidth(UnitValue.createPercentValue(100));
    List<List<String>> resultSet = CsvTo2DList.convert(SRC, "|");
    List<String> header = resultSet.remove(0);
    for (String field : header) {
        table.addHeaderCell(field);
    }
    for (List<String> record : resultSet) {
        table.addCell(record.get(0));
        table.addCell(record.get(1));
        Cell cell = new Cell().add(new Paragraph(record.get(2)));
        cell.setNextRenderer(new RunlengthRenderer(cell, record.get(5)));
        table.addCell(cell);
        table.addCell(record.get(3));
        table.addCell(record.get(4));
        table.addCell(record.get(5));
    }
    document.add(table);
    document.close();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) CsvTo2DList(com.itextpdf.highlevel.util.CsvTo2DList) List(java.util.List) 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