Example usage for com.lowagie.text Element ALIGN_TOP

List of usage examples for com.lowagie.text Element ALIGN_TOP

Introduction

In this page you can find the example usage for com.lowagie.text Element ALIGN_TOP.

Prototype

int ALIGN_TOP

To view the source code for com.lowagie.text Element ALIGN_TOP.

Click Source Link

Document

A possible value for vertical alignment.

Usage

From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.PdfMapper.java

License:Open Source License

@Override
protected IITextContainer startVisitTableCell(final XWPFTableCell cell, IITextContainer pdfTableContainer,
        boolean firstRow, boolean lastRow, boolean firstCol, boolean lastCol, List<XWPFTableCell> vMergeCells)
        throws Exception {
    XWPFTableRow row = cell.getTableRow();
    XWPFTable table = row.getTable();/*from w  w w  .  j a  va  2  s .  c  om*/

    // 1) store table cell info
    stylesDocument.getTableInfo(table).addCellInfo(cell, firstRow, lastRow, firstCol, lastCol);

    // 2) create PDF cell
    StylableTable pdfPTable = (StylableTable) pdfTableContainer;

    StylableTableCell pdfPCell = pdfDocument.createTableCell(pdfPTable);
    // pdfPCell.setUseAscender( true );
    // pdfPCell.setUseDescender( true );

    XWPFTableCell lastVMergedCell = null;
    if (vMergeCells != null) {
        pdfPCell.setRowspan(vMergeCells.size());
        lastVMergedCell = vMergeCells.get(vMergeCells.size() - 1);
        stylesDocument.getTableInfo(table).addCellInfo(lastVMergedCell, false, lastRow, firstCol, lastCol);
    }

    // border-top
    TableCellBorder borderTop = stylesDocument.getTableCellBorderWithConflicts(cell, BorderSide.TOP);
    if (borderTop != null) {
        boolean borderTopInside = stylesDocument.isBorderInside(cell, BorderSide.TOP);
        if (borderTopInside) {
            // Manage conflict border with the adjacent border bottom

        }
    }

    pdfPCell.setBorderTop(borderTop, false);

    // border-bottom

    XWPFTableCell theCell = lastVMergedCell != null ? lastVMergedCell : cell;
    TableCellBorder borderBottom = stylesDocument.getTableCellBorderWithConflicts(theCell, BorderSide.BOTTOM);
    pdfPCell.setBorderBottom(borderBottom, stylesDocument.isBorderInside(theCell, BorderSide.BOTTOM));

    // border-left
    TableCellBorder borderLeft = stylesDocument.getTableCellBorderWithConflicts(cell, BorderSide.LEFT);
    pdfPCell.setBorderLeft(borderLeft, stylesDocument.isBorderInside(cell, BorderSide.LEFT));

    // border-right
    TableCellBorder borderRight = stylesDocument.getTableCellBorderWithConflicts(cell, BorderSide.RIGHT);
    pdfPCell.setBorderRight(borderRight, stylesDocument.isBorderInside(cell, BorderSide.RIGHT));

    // Text direction <w:textDirection
    CTTextDirection direction = stylesDocument.getTextDirection(cell);
    if (direction != null) {
        int dir = direction.getVal().intValue();
        switch (dir) {
        case STTextDirection.INT_BT_LR:
            pdfPCell.setRotation(90);
            break;
        case STTextDirection.INT_TB_RL:
            pdfPCell.setRotation(270);
            break;
        }
    }

    // Colspan
    BigInteger gridSpan = stylesDocument.getTableCellGridSpan(cell);
    if (gridSpan != null) {
        pdfPCell.setColspan(gridSpan.intValue());
    }

    // Background Color
    Color backgroundColor = stylesDocument.getTableCellBackgroundColor(cell);
    if (backgroundColor != null) {
        pdfPCell.setBackgroundColor(Converter.toAwtColor(backgroundColor));
    }

    // Vertical aligment
    Enum jc = stylesDocument.getTableCellVerticalAlignment(cell);
    if (jc != null) {
        switch (jc.intValue()) {
        case STVerticalJc.INT_BOTTOM:
            pdfPCell.setVerticalAlignment(Element.ALIGN_BOTTOM);
            break;
        case STVerticalJc.INT_CENTER:
            pdfPCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            break;
        case STVerticalJc.INT_TOP:
            pdfPCell.setVerticalAlignment(Element.ALIGN_TOP);
            break;
        }
    }
    // Cell margin
    Float marginTop = stylesDocument.getTableCellMarginTop(cell);
    if (marginTop == null) {
        marginTop = stylesDocument.getTableRowMarginTop(row);
        if (marginTop == null) {
            marginTop = stylesDocument.getTableMarginTop(table);
        }
    }
    if (marginTop != null) {
        pdfPCell.setPaddingTop(marginTop);
    }
    Float marginBottom = stylesDocument.getTableCellMarginBottom(cell);
    if (marginBottom == null) {
        marginBottom = stylesDocument.getTableRowMarginBottom(row);
        if (marginBottom == null) {
            marginBottom = stylesDocument.getTableMarginBottom(table);
        }
    }
    if (marginBottom != null && marginBottom > 0) {
        pdfPCell.setPaddingBottom(marginBottom);
    }
    Float marginLeft = stylesDocument.getTableCellMarginLeft(cell);
    if (marginLeft == null) {
        marginLeft = stylesDocument.getTableRowMarginLeft(row);
        if (marginLeft == null) {
            marginLeft = stylesDocument.getTableMarginLeft(table);
        }
    }
    if (marginLeft != null) {
        pdfPCell.setPaddingLeft(marginLeft);
    }
    Float marginRight = stylesDocument.getTableCellMarginRight(cell);
    if (marginRight == null) {
        marginRight = stylesDocument.getTableRowMarginRight(row);
        if (marginRight == null) {
            marginRight = stylesDocument.getTableMarginRight(table);
        }
    }
    if (marginRight != null) {
        pdfPCell.setPaddingRight(marginRight);
    }

    // Row height
    TableHeight tableHeight = stylesDocument.getTableRowHeight(row);
    if (tableHeight != null) {
        if (tableHeight.minimum) {
            pdfPCell.setMinimumHeight(tableHeight.height);
        } else {
            pdfPCell.setFixedHeight(tableHeight.height);
        }
    }
    // No wrap
    Boolean noWrap = stylesDocument.getTableCellNoWrap(cell);
    if (noWrap != null) {
        pdfPCell.setNoWrap(noWrap);
    }
    return pdfPCell;
}

From source file:jdbreport.model.io.pdf.itext2.ITextWriter.java

License:Apache License

protected int toPdfVAlignment(int verticalAlignment) {
    switch (verticalAlignment) {
    case CellStyle.TOP:
        return Element.ALIGN_TOP;
    case CellStyle.BOTTOM:
        return Element.ALIGN_BOTTOM;
    case CellStyle.CENTER:
        return Element.ALIGN_CENTER;
    }//from w  w w.  j a v  a2  s  .com
    return Element.ALIGN_TOP;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.LIGHT_GRAY);
    celda.setBorderWidth(borde);/*www. j av a2s  .  c om*/
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde,
        int padding) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.LIGHT_GRAY);
    celda.setBorderWidth(borde);//  w  w  w . j a  v  a  2 s.  co m
    celda.setPadding(padding);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDFBottom(String texto, int tipo, int tamanio, int estilo, int alineacion,
        int borde, int padding, int colspan) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.WHITE);
    celda.setColspan(colspan);/*from w  ww. j  a va  2s. c o  m*/
    celda.setBorder(borde);
    celda.setPadding(padding);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDFCarnetOpciones(String texto, int tipo, int tamanio, int estilo,
        int alineacion, int borde, int padding, int colspan, Color color) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.black);
    celda.setBackgroundColor(color);//from  w ww.j a  v a2s . c om
    celda.setColspan(colspan);
    celda.setBorderWidth(borde);
    celda.setPadding(0);
    celda.setPaddingBottom(padding);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDFCarnet(String texto, int tipo, int tamanio, int estilo, int alineacion,
        int borde, int padding, int colspan) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.WHITE);
    celda.setColspan(colspan);// w  w  w. j ava 2s  .c  o m
    celda.setBorderWidth(0);
    celda.setBorderWidthBottom(borde);
    celda.setPadding(0);
    celda.setPaddingBottom(padding);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDFCarnet(String texto, int tipo, int tamanio, int estilo, int alineacion,
        int borde, int padding, int colspan, Color color) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, color)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.WHITE);
    celda.setColspan(colspan);//from  w  ww.j  a  v a  2s .  c o m
    celda.setBorderWidth(0);
    celda.setBorderWidthBottom(borde);
    celda.setPadding(0);
    celda.setPaddingBottom(padding);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde,
        Color color) {/*  w  w w .j a v a2  s. c  o  m*/
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo)));
    celda.setHorizontalAlignment(alineacion);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.LIGHT_GRAY);
    celda.setBorderWidth(borde);
    celda.setBackgroundColor(color);
    return celda;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde,
        Color color, int padding, int colspan) {
    PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo)));
    celda.setHorizontalAlignment(alineacion);
    celda.setPadding(padding);//from  ww w  .  j  a v a2s .  c  o  m
    celda.setColspan(colspan);
    celda.setVerticalAlignment(Element.ALIGN_TOP);
    celda.setBorderColor(Color.LIGHT_GRAY);
    celda.setBorderWidth(borde);
    celda.setBackgroundColor(color);
    return celda;
}