Search in sources :

Example 26 with Cell

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

the class C05E08_JekyllHydeTableV1 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);
    }
    Cell cell = new Cell(1, 6).add(new Paragraph("Continued on next page..."));
    table.addFooterCell(cell).setSkipLastFooter(true);
    for (List<String> record : resultSet) {
        for (String field : record) {
            table.addCell(field);
        }
    }
    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 27 with Cell

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

the class C05E11_JekyllHydeTableV4 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)));
        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 28 with Cell

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

the class CellProperties 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(2)).useAllAvailableWidth();
    PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
    table.addCell(new Cell().add(new Paragraph("Test 1")).setHeight(50).setDestination("Top"));
    Style style = new Style();
    style.setBackgroundColor(ColorConstants.YELLOW);
    table.addCell(new Cell().setBorder(new DottedBorder(5)).add(new Paragraph("Test 2")).addStyle(style).setRelativePosition(10, 10, 50, 10));
    table.addCell(new Cell().add(new Paragraph("Test 3")).setVerticalAlignment(VerticalAlignment.BOTTOM));
    table.addCell(new Cell().add(ParagraphProperties.getNewParagraphInstance()).setHyphenation(new HyphenationConfig("en", "uk", 3, 3)));
    table.addCell(new Cell().add(new Paragraph("Rotated")).setRotationAngle(Math.PI / 18).setFont(font).setFontSize(8).setFontColor(ColorConstants.RED));
    table.addCell(new Cell().add(new Paragraph("Centered")).setTextAlignment(TextAlignment.CENTER).setAction(PdfAction.createGoTo("Top")));
    table.addCell(new Cell().add(new Paragraph("Test 5")).setBackgroundColor(ColorConstants.BLUE));
    table.addCell(new Cell().add(ParagraphProperties.getNewParagraphInstance()).setBackgroundColor(ColorConstants.RED).setPaddingLeft(20).setPaddingRight(50));
    table.addCell(new Cell().add(new Paragraph("Test 7")).setBackgroundColor(ColorConstants.RED));
    table.addCell(new Cell().add(new Paragraph("Test 8")).setBackgroundColor(ColorConstants.BLUE).setMarginBottom(10));
    table.addCell(new Cell().add(new Paragraph("Test 9")).setBackgroundColor(ColorConstants.BLUE));
    table.addCell(new Cell().add(new Paragraph("Test 10")).setBackgroundColor(ColorConstants.RED));
    table.addCell(new Cell().add(ParagraphProperties.getNewParagraphInstance()).setBackgroundColor(ColorConstants.RED).setMargin(50).setPadding(30));
    table.addCell(new Cell().add(new Paragraph("Test 12")).setBackgroundColor(ColorConstants.BLUE));
    document.add(table);
    SolidBorder border = new SolidBorder(ColorConstants.RED, 2);
    Cell cell = new Cell().add(new Paragraph("Test")).setFixedPosition(100, 400, 350).setBorder(border).setBackgroundColor(ColorConstants.BLUE).setHeight(100).setHorizontalAlignment(HorizontalAlignment.CENTER);
    document.add(cell);
    document.close();
}
Also used : Table(com.itextpdf.layout.element.Table) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfFont(com.itextpdf.kernel.font.PdfFont) Style(com.itextpdf.layout.Style) HyphenationConfig(com.itextpdf.layout.hyphenation.HyphenationConfig) 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 29 with Cell

use of com.itextpdf.layout.element.Cell in project ComponentManagement by Bac3Phi.

the class ReportPaymentController method addTablePayments.

private void addTablePayments(Document document) throws SQLException {
    float[] pointColumnWidths = { 200F, 200F, 200F };
    Table table = new Table(pointColumnWidths);
    table.addCell(new Cell().add("Mã Chi Tiết Chi").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Tên Mặt Hàng").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Tổng Nhập").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    resultSet = dbConn.getData("select MaCTC, TenMH, TongNhap\n" + "from CHITIETCHI CTC join MATHANG MH on CTC.MaMH = MH.MaMH\n" + "where MaBCTC = '" + txtPaymentReportId.getText() + "'");
    while (resultSet.next()) {
        table.addCell(new Cell().add(resultSet.getString("MaCTC")).setTextAlignment(TextAlignment.LEFT).setFontSize(12).setFont(font));
        table.addCell(new Cell().add(resultSet.getString("TenMH")).setTextAlignment(TextAlignment.LEFT).setFontSize(12).setFont(font));
        table.addCell(new Cell().add(String.valueOf(resultSet.getLong("TongNhap"))).setTextAlignment(TextAlignment.RIGHT).setFontSize(12).setFont(font));
    }
    document.add(table);
}
Also used : Table(com.itextpdf.layout.element.Table) Cell(com.itextpdf.layout.element.Cell)

Example 30 with Cell

use of com.itextpdf.layout.element.Cell in project ComponentManagement by Bac3Phi.

the class ReportPaymentController method addTableRecetpts.

private void addTableRecetpts(Document document) throws SQLException {
    float[] pointColumnWidths = { 200F, 200F, 200F };
    Table table = new Table(pointColumnWidths);
    table.addCell(new Cell().add("Mã Chi Tiết Thu").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Tên Mặt Hàng").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    table.addCell(new Cell().add("Tổng Bán").setTextAlignment(TextAlignment.CENTER).setFontSize(14).setFont(font_bold));
    resultSet = dbConn.getData("select MaCTT, TenMH, TongBan\n" + "from CHITIETTHU CTT join MATHANG MH on CTT.MaMH = MH.MaMH\n" + "where MaBCTC = '" + txtPaymentReportId.getText() + "'");
    while (resultSet.next()) {
        table.addCell(new Cell().add(resultSet.getString("MaCTT")).setTextAlignment(TextAlignment.LEFT).setFontSize(12).setFont(font));
        table.addCell(new Cell().add(resultSet.getString("TenMH")).setTextAlignment(TextAlignment.LEFT).setFontSize(12).setFont(font));
        table.addCell(new Cell().add(String.valueOf(resultSet.getLong("TongBan"))).setTextAlignment(TextAlignment.RIGHT).setFontSize(12).setFont(font));
    }
    document.add(table);
}
Also used : Table(com.itextpdf.layout.element.Table) Cell(com.itextpdf.layout.element.Cell)

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