Example usage for com.itextpdf.text.pdf PdfPCell setColumn

List of usage examples for com.itextpdf.text.pdf PdfPCell setColumn

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPCell setColumn.

Prototype

public void setColumn(ColumnText column) 

Source Link

Document

Sets the columntext in the cell.

Usage

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * /* ww  w .  jav  a 2s . co m*/
 *  box 
 *
 * @param section box  section ?
 * @param e box   element
 * @throws Exception
 */
public static void setBox(Section section, Element e) throws Exception {

    PdfPTable t = new PdfPTable(1);
    t.setSpacingBefore(1);
    t.setSpacingAfter(12);

    if (e.getAttributeValue("width") != null)
        t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width")));

    PdfPCell cell = new PdfPCell();
    if (e.getAttributeValue("option") != null) {

        ColumnText col = new ColumnText(null);
        for (Element e1 : e.getChildren()) {
            if (e1.getAttributeValue("type").equals("red"))
                col.addText(new Phrase(e1.getText(), fnBoxRed));
            else
                col.addText(new Phrase(e1.getText(), fnBox));
        }
        cell.setColumn(col);

    } else {
        cell.setPhrase(new Phrase(e.getText(), fnBox));
    }

    cell.setPaddingLeft(10);
    cell.setLeading(0.0F, 1.8F);
    cell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(new BaseColor(238, 236, 225));

    t.addCell(cell);

    section.add(t);

}

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * //from ww  w.  j ava 2  s  .  c o m
 * box (Backgroud : Black)
 *
 * @param section box  section ?
 * @param e box   element
 * @throws Exception
 */
public static void setBoxB(Section section, Element e) throws Exception {

    PdfPTable t = new PdfPTable(1);
    t.setSpacingBefore(1);
    t.setSpacingAfter(12);

    if (e.getAttributeValue("width") != null)
        t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width")));

    PdfPCell cell = new PdfPCell();
    if (e.getAttributeValue("option") != null) {

        ColumnText col = new ColumnText(null);
        for (Element e1 : e.getChildren()) {
            if (e1.getAttributeValue("type").equals("red"))
                col.addText(new Phrase(e1.getText(), fnBoxRed));
            else
                col.addText(new Phrase(e1.getText(), fnBoxWhite));
        }
        cell.setColumn(col);

    } else {
        cell.setPhrase(new Phrase(e.getText(), fnBoxWhite));
    }

    cell.setPaddingLeft(10);
    cell.setLeading(0.0F, 1.8F);
    cell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(new BaseColor(0, 0, 0));

    t.addCell(cell);

    section.add(t);

}

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * //from  w  ww .  j ava2 s.c om
 * box (Backgroud : White)
 *
 * @param section box  section ?
 * @param e box   element
 * @throws Exception
 */
public static void setBoxW(Section section, Element e) throws Exception {

    PdfPTable t = new PdfPTable(1);
    t.setSpacingBefore(1);
    t.setSpacingAfter(12);

    if (e.getAttributeValue("width") != null)
        t.setTotalWidth(Float.parseFloat(e.getAttributeValue("width")));

    PdfPCell cell = new PdfPCell();
    if (e.getAttributeValue("option") != null) {

        ColumnText col = new ColumnText(null);
        for (Element e1 : e.getChildren()) {
            if (e1.getAttributeValue("type").equals("red"))
                col.addText(new Phrase(e1.getText(), fnBoxRed));
            else
                col.addText(new Phrase(e1.getText(), fnBoxBlack));
        }
        cell.setColumn(col);

    } else {
        cell.setPhrase(new Phrase(e.getText(), fnBoxBlack));
    }

    cell.setPaddingLeft(10);
    cell.setLeading(0.0F, 1.8F);
    cell.setVerticalAlignment(com.itextpdf.text.Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(new BaseColor(255, 255, 255));

    t.addCell(cell);

    section.add(t);

}