Search in sources :

Example 1 with DashedBorder

use of com.itextpdf.layout.borders.DashedBorder 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 2 with DashedBorder

use of com.itextpdf.layout.borders.DashedBorder in project i7js-highlevel by itext.

the class C05E04_ColumnHeights method createPdf.

public void createPdf(String dest) throws IOException {
    // Initialize PDF document
    PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
    Paragraph p = new Paragraph("The Strange Case of\nDr. Jekyll\nand\nMr. Hyde").setBorder(new DashedBorder(0.3f));
    // Initialize document
    Document document = new Document(pdf);
    Table table = new Table(UnitValue.createPercentArray(new float[] { 1 }));
    table.setWidth(UnitValue.createPercentValue(100));
    table.addCell(p);
    Cell cell = new Cell().setHeight(45).add(p);
    table.addCell(cell);
    cell = new Cell().setMinHeight(45).add(p);
    table.addCell(cell);
    cell = new Cell().setMinHeight(135).add(p);
    table.addCell(cell);
    cell = new Cell().setMaxHeight(45).add(p);
    table.addCell(cell);
    cell = new Cell().setMaxHeight(135).add(p);
    table.addCell(cell);
    cell = new Cell().add(p).setRotationAngle(Math.PI / 6);
    table.addCell(cell);
    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) Cell(com.itextpdf.layout.element.Cell) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) Paragraph(com.itextpdf.layout.element.Paragraph)

Aggregations

PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)2 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)2 Document (com.itextpdf.layout.Document)2 DashedBorder (com.itextpdf.layout.borders.DashedBorder)2 Cell (com.itextpdf.layout.element.Cell)2 Paragraph (com.itextpdf.layout.element.Paragraph)2 Table (com.itextpdf.layout.element.Table)2 DottedBorder (com.itextpdf.layout.borders.DottedBorder)1 SolidBorder (com.itextpdf.layout.borders.SolidBorder)1