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

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

Introduction

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

Prototype

public void setNoWrap(boolean noWrap) 

Source Link

Document

Setter for property noWrap.

Usage

From source file:com.norbsoft.pdfconverter.helpers.PDFHelper.java

License:Open Source License

private PdfPTable table(Form form) {
    int cellPadding = 5;
    PdfPTable table = new PdfPTable(8);
    table.setSpacingBefore(20);/*from w w w .ja  v a2 s.  c  o  m*/

    try {
        table.setWidths(new int[] { 100, 120, 30, 60, 60, 50, 50, 50 });
    } catch (DocumentException e) {
        Log.e(TAG, "Width error:" + e.getMessage());
    }

    PdfPCell cell = new PdfPCell(new Paragraph("Adres: " + form.getAddress(), normal));
    cell.setColspan(8);
    cell.setPadding(cellPadding);
    cell.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP);
    cell.setBorderColorBottom(BaseColor.BLACK);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("Odbiorca: " + form.getOwner(), normal));
    cell.setColspan(8);
    cell.setPadding(cellPadding);
    cell.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
    cell.setBorderColorBottom(BaseColor.BLACK);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("Data: " + form.getDate(), normal));
    cell.setColspan(3);
    cell.setPadding(cellPadding);
    cell.setBorder(Rectangle.LEFT | Rectangle.BOTTOM);
    cell.setBorderColorBottom(BaseColor.BLACK);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("tel: " + form.getPhone(), normal));
    cell.setColspan(5);
    cell.setPadding(cellPadding);
    cell.setBorder(Rectangle.RIGHT | Rectangle.BOTTOM);
    cell.setBorderColorBottom(BaseColor.BLACK);
    table.addCell(cell);

    //Header
    Paragraph p = new Paragraph("WODOMIERZ", bold);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setNoWrap(true);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph("Nr fabryczny", bold);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph("DN", bold);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph("Typ\r\nProducent", bold);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph("Stan w (m3)", bold);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph("Rok\r\nlegalizacji", bold);
    cell = new PdfPCell(p);
    ;
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph("Czy plomba\r\nlegalizacyjna jest\r\nuszkodzona?", bold);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    //First row
    cell = new PdfPCell(new Paragraph("Zamontowany", bold));
    cell.setNoWrap(true);
    cell.setPadding(cellPadding);
    table.addCell(cell);

    p = new Paragraph(form.getNewSN(), normal);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph(form.getNewDN(), normal);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph(form.getNewType() + "\r\n" + form.getNewManufacturer(), normal);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph(form.getNewState(), normal);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph(form.getNewYear(), normal);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    if (form.getNewSeal().equals("Tak"))
        p = new Paragraph("tak", normal);
    else
        p = new Paragraph("tak", strike);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    if (form.getNewSeal().equals("Nie"))
        p = new Paragraph("nie", normal);
    else
        p = new Paragraph("nie", strike);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    //Second row
    cell = new PdfPCell(new Paragraph("Wymontowany", bold));
    cell.setNoWrap(true);
    cell.setPadding(cellPadding);
    table.addCell(cell);

    p = new Paragraph(form.getOldSN(), normal);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph(form.getOldDN(), normal);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph(form.getOldType() + "\r\n" + form.getOldManufacturer(), normal);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph(form.getOldState(), normal);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    p = new Paragraph(form.getOldYear(), normal);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    if (form.getOldSeal().equals("Tak"))
        p = new Paragraph("tak", normal);
    else
        p = new Paragraph("tak", strike);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    if (form.getOldSeal().equals("Nie"))
        p = new Paragraph("nie", normal);
    else
        p = new Paragraph("nie", strike);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    //Third row
    cell = new PdfPCell(new Paragraph("Plomba nr 1", bold));
    cell.setPadding(cellPadding);
    table.addCell(cell);

    p = new Paragraph(form.getSealFirst(), normal);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("Przyczyna wymiany: " + form.getReason(), normal));
    cell.setPadding(cellPadding);
    cell.setColspan(5);
    table.addCell(cell);

    //Fourth row
    cell = new PdfPCell(new Paragraph("Plomba nr 2", bold));
    cell.setPadding(cellPadding);
    table.addCell(cell);

    p = new Paragraph(form.getSealSecond(), normal);
    cell = new PdfPCell(p);
    cell.setPadding(cellPadding);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph("Umiejscowienie wodomierza: " + form.getPlacement(), normal));
    cell.setPadding(cellPadding);
    cell.setColspan(5);
    table.addCell(cell);

    //Fourth row
    cell = new PdfPCell(new Paragraph("Nr moduu\r\nradiowego", bold));
    cell.setPadding(cellPadding);
    table.addCell(cell);

    cell = new PdfPCell(new Paragraph(form.getNewModuleNumber(), normal));
    cell.setPadding(cellPadding);
    cell.setColspan(7);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    table.setWidthPercentage(100);
    return table;
}

From source file:edu.harvard.mcz.precapture.ui.ContainerLabel.java

License:Open Source License

/**
 * /*from   ww w  .  j a  v a  2s  .c o m*/
 * @return a PDF paragraph cell containing a text encoding of the fields in this set.
 */
public PdfPCell toPDFCell(LabelDefinitionType printDefinition) {
    PdfPCell cell = new PdfPCell();
    ;
    if (printDefinition.getTextOrentation().toString().toLowerCase()
            .equals(TextOrentationType.VERTICAL.toString().toLowerCase())) {
        log.debug("Print orientation of text is Vertical");
        cell.setRotation(90);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
    }
    cell.setBorderColor(BaseColor.LIGHT_GRAY);
    cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
    cell.disableBorderSide(PdfPCell.RIGHT);
    cell.setPaddingLeft(3);
    cell.setNoWrap(false);

    int leading = (int) (fields.get(0).getField().getFontSize() + printDefinition.getFontDelta()) - 1;
    Paragraph higher = new Paragraph(leading, "", new Font(Font.FontFamily.TIMES_ROMAN,
            fields.get(0).getField().getFontSize() + printDefinition.getFontDelta(), Font.NORMAL));
    higher.setSpacingBefore(0);
    higher.setSpacingAfter(0);
    boolean added = false;
    boolean hasContent = false;
    for (int i = 0; i < fields.size(); i++) {
        log.debug(i);
        if (fields.get(i).getField().isNewLine() || (i == fields.size() - 1)) {
            if (!higher.isEmpty()) {
                log.debug(higher.getContent());
                cell.addElement(higher);
            }
            leading = (int) (fields.get(i).getField().getFontSize() + printDefinition.getFontDelta()) - 1;
            higher = new Paragraph(leading, "", new Font(Font.FontFamily.TIMES_ROMAN,
                    fields.get(i).getField().getFontSize() + printDefinition.getFontDelta(), Font.NORMAL));
            higher.setSpacingBefore(0);
            higher.setSpacingAfter(0);
            added = false;
            hasContent = false;
        }
        log.debug(fields.get(i).getTextField().getText().trim());
        Chunk chunk = new Chunk(fields.get(i).getTextField().getText().trim());
        if (fields.get(i).getField().isUseItalic()) {
            chunk.setFont(new Font(Font.FontFamily.TIMES_ROMAN,
                    fields.get(i).getField().getFontSize() + printDefinition.getFontDelta(), Font.ITALIC));
        } else {
            chunk.setFont(new Font(Font.FontFamily.TIMES_ROMAN,
                    fields.get(i).getField().getFontSize() + printDefinition.getFontDelta(), Font.NORMAL));
        }
        if (!chunk.isEmpty()) {
            hasContent = true;
            higher.add(chunk);
            log.debug(fields.get(i).getField().getSuffix());
            if (fields.get(i).getField().getSuffix() != null
                    && fields.get(i).getField().getSuffix().length() > 0) {
                higher.add(new Chunk(fields.get(i).getField().getSuffix()));
            }
            if (fields.get(i).getTextField().getText().trim().length() > 0) {
                // add a trailing space as a separator if there was something to separate.
                higher.add(new Chunk(" "));
            }
        }
    }
    if (!added) {
        log.debug(higher.getContent());
        cell.addElement(higher);
    }
    String extraText = PreCaptureSingleton.getInstance().getProperties().getProperties()
            .getProperty(PreCaptureProperties.KEY_EXTRAHUMANTEXT);
    if (extraText != null && extraText.length() > 0) {
        log.debug(extraText);
        cell.addElement(new Chunk(extraText));
    }

    return cell;
}

From source file:fc.extensions.itext.Writer.java

License:MIT License

public void addCell(PdfPTable table, String content, int fontSize, float borderWidth, int columnSpan) {
    PdfPCell pCell = new PdfPCell();
    if (columnSpan > 1) {
        pCell.setColspan(columnSpan);/*w  w w  .  j av  a 2 s.c o  m*/
    }
    pCell.setBorderWidth(borderWidth);
    pCell.setPhrase(new Phrase(content, getFont(fontSize)));
    pCell.setNoWrap(false);
    pCell.setHorizontalAlignment(PdfContentByte.ALIGN_LEFT);
    pCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(pCell);
}

From source file:fc.extensions.itext.Writer.java

License:MIT License

public void addAnsiCell(PdfPTable table, String content, int fontSize, float borderWidth, int columnSpan) {
    PdfPCell pCell = new PdfPCell();
    if (columnSpan > 1) {
        pCell.setColspan(columnSpan);//w  w  w .ja  va  2  s .c om
    }
    pCell.setBorderWidth(borderWidth);
    pCell.setPhrase(new Phrase(content, getAnsiFont(fontSize)));
    pCell.setNoWrap(false);
    pCell.setHorizontalAlignment(PdfContentByte.ALIGN_LEFT);
    pCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(pCell);
}

From source file:fxml.test.PDFService.java

public PdfPCell getCellForString(String args, int colSpan, boolean border, int vertical, int horizontal,
        Font font, boolean wrap) {

    PdfPCell cell = new PdfPCell(new Paragraph(args, font));
    if (colSpan != 0) {
        cell.setColspan(colSpan);//from w w  w.  j  a va 2s. c  o m
    }
    cell.setVerticalAlignment(vertical);
    cell.setHorizontalAlignment(horizontal);
    if (!border) {
        cell.setBorder(Rectangle.NO_BORDER);
    }
    if (wrap) {
        cell.setNoWrap(true);
    }
    return cell;
}

From source file:fxml.test.PDFService.java

public PdfPCell getCellForHeaderString(String args, int colSpan, boolean flag, int vertical, int horizontal,
        Font font, boolean wrap) {

    PdfPCell cell = new PdfPCell(new Paragraph(args, font));
    if (colSpan != 0) {
        cell.setColspan(colSpan);//from  w  w w.  j  ava 2s  . co m
    }
    cell.setVerticalAlignment(vertical);
    cell.setHorizontalAlignment(horizontal);
    cell.setPaddingTop(0.8f);
    if (!flag) {
        cell.setBorder(Rectangle.NO_BORDER);
    }

    if (wrap) {
        cell.setNoWrap(true);
    }
    return cell;

}

From source file:jdbreport.model.io.pdf.itext5.PdfWriter.java

License:Apache License

private PdfPCell writeCell(ReportModel model, jdbreport.model.Cell srcCell, int row, int col)
        throws BadElementException, IOException, SaveReportException {

    CellStyle style = model.getStyles(srcCell.getStyleId());

    java.awt.Rectangle rect = model.getCellRect(row, col, true, true);

    float h = (float) Units.PT.setYPixels((int) rect.getHeight());
    float w = (float) Units.PT.setXPixels((int) rect.getWidth());

    PdfPCell pdfCell;

    if (srcCell.getPicture() != null) {
        Icon icon = srcCell.getPicture().getIcon();
        java.awt.Image awtImage = ((ImageIcon) icon).getImage();

        com.itextpdf.text.Image image = awtImageToImage(awtImage, srcCell, w, h);
        pdfCell = new PdfPCell(image);
    } else {//from w w  w .  ja  v a  2  s  .c o m
        pdfCell = new PdfPCell();

        String text = null;

        if (srcCell.getValue() instanceof CellValue<?>) {

            StringWriter strWriter = new StringWriter();
            PrintWriter printWriter = new PrintWriter(strWriter);

            if (!((CellValue<?>) srcCell.getValue()).write(printWriter, model, row, col, this,
                    ReportBook.PDF)) {
                java.awt.Image awtImage = ((CellValue<?>) srcCell.getValue()).getAsImage(model, row, col);
                if (awtImage != null) {
                    com.itextpdf.text.Image image = awtImageToImage(awtImage, srcCell, w, h);
                    pdfCell.setImage(image);
                }
            } else {
                text = strWriter.getBuffer().toString();
            }

        } else {
            if (jdbreport.model.Cell.TEXT_HTML.equals(srcCell.getContentType())) {
                writeHTMLText(model.getStyles(srcCell.getStyleId()), srcCell, pdfCell);
            } else {
                text = model.getCellText(srcCell);
            }
        }

        if (text != null && text.length() > 0) {
            com.itextpdf.text.Font font;
            if (fonts.containsKey(style.getId())) {
                font = fonts.get(style.getId());
            } else {
                font = getFontMapper().styleToPdf(style);
                fonts.put(style.getId(), font);
            }
            Paragraph p;
            if (font != null) {
                p = new Paragraph(text, font);
            } else {
                p = new Paragraph(text);
            }
            pdfCell.setPhrase(p);
        }
    }

    pdfCell.setFixedHeight(h);
    pdfCell.setPadding(1);
    pdfCell.setBackgroundColor(new BaseColor(style.getBackground().getRGB()));
    pdfCell.setHorizontalAlignment(toPdfHAlignment(style.getHorizontalAlignment()));
    pdfCell.setVerticalAlignment(toPdfVAlignment(style.getVerticalAlignment()));

    if (style.getAngle() != 0) {
        pdfCell.setRotation(roundAngle(style.getAngle()));
    }

    assignBorders(style, pdfCell);
    pdfCell.setNoWrap(!style.isWrapLine());

    if (srcCell.getColSpan() > 0) {
        pdfCell.setColspan(srcCell.getColSpan() + 1);
    }
    if (srcCell.getRowSpan() > 0) {
        pdfCell.setRowspan(srcCell.getRowSpan() + 1);
    }

    return pdfCell;
}

From source file:net.digitstar.vanadio.helpers.PdfHelper.java

License:Apache License

public static PdfPCell newCell(CellStyle style) {
    PdfPCell cell = new PdfPCell();
    if (style != null) {
        if (style.getNestedTable() != null) {
            cell = new PdfPCell(style.getNestedTable());
            style.setNestedTable(null);//  ww w . j  a va 2s.  co  m
        } else if (style.getImage() != null) {
            cell = new PdfPCell(style.getImage(), style.isFitImage());
            style.setImage(null);
        } else if (style.getText() != null) {
            cell = new PdfPCell(style.getText());
            style.setText((String) null);
        }

        cell.setColspan(style.getColspan());
        cell.setRowspan(style.getRowspan());

        cell.setMinimumHeight(style.getMinimumHeight());
        cell.setFixedHeight(style.getFixedHeight());

        cell.setNoWrap(style.isNoWrap());

        cell.setRotation(style.getRotation().getValue());

        style = Alignment.assign(style);

        cell.setHorizontalAlignment(style.getHorizAlign().getValue());
        cell.setVerticalAlignment(style.getVertAlign().getValue());

        cell.setUseVariableBorders(style.isUseVariableBorders());
        cell.setUseBorderPadding(style.isUseBorderPadding());

        if (!style.getBorderWidth().isAllSideEqual()) {
            cell.setBorderWidthBottom(style.getBorderWidth().getBottom());
            cell.setBorderWidthLeft(style.getBorderWidth().getLeft());
            cell.setBorderWidthRight(style.getBorderWidth().getRight());
            cell.setBorderWidthTop(style.getBorderWidth().getTop());
        } else {
            cell.setBorderWidth(style.getBorderWidth().getValue());
        }

        cell.setPaddingBottom(style.getPadding().getBottom());
        cell.setPaddingLeft(style.getPadding().getLeft());
        cell.setPaddingRight(style.getPadding().getRight());
        cell.setPaddingTop(style.getPadding().getTop());

        cell.setBorderColorBottom(style.getBorderColor().getBottom());
        cell.setBorderColorLeft(style.getBorderColor().getLeft());
        cell.setBorderColorRight(style.getBorderColor().getRight());
        cell.setBorderColorTop(style.getBorderColor().getTop());

        cell.setBorder(style.getBorder().getValue());

        cell.setBackgroundColor(style.getBackgroundColor());
        if (style.getGreyFill() >= 0) {
            cell.setGrayFill(style.getGreyFill());
        }
    }
    return cell;
}

From source file:printers.AbstractHorariosPrinter.java

License:Open Source License

private PdfPCell createCeldaHoras(String texto) {
    Font font = new Font(Font.FontFamily.HELVETICA, 10);

    Paragraph p = new Paragraph(texto, font);
    p.setAlignment(Paragraph.ALIGN_CENTER);
    PdfPCell c = new PdfPCell(p);
    c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
    c.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    c.setGrayFill(.9f);/*  w w w .  ja va2  s  .  co  m*/
    c.setNoWrap(true);
    c.setFixedHeight(alturaCeldas);
    return c;
}

From source file:ro.nextreports.engine.exporter.PdfExporter.java

License:Apache License

private PdfPCell renderPdfCell(BandElement bandElement, Object value, int gridRow, int rowSpan, int colSpan,
        boolean image, int column) {
    Map<String, Object> style = buildCellStyleMap(bandElement, value, gridRow, column, colSpan);

    FontFactoryImp fact = new FontFactoryImp();
    com.itextpdf.text.Font fnt;/*ww w .ja  va  2s  . co m*/
    if (bandElement != null) {
        fontName = (String) style.get(StyleFormatConstants.FONT_NAME_KEY);
        int size = ((Float) style.get(StyleFormatConstants.FONT_SIZE)).intValue();
        fnt = getFont(size);
    } else {
        fnt = getFont(10);
    }

    PdfPCell cell;
    if (image) {
        if (value == null) {
            cell = new PdfPCell(new Phrase(IMAGE_NOT_FOUND));
        } else {
            ImageBandElement ibe = (ImageBandElement) bandElement;
            try {
                byte[] imageBytes = getImage((String) value);
                cell = getImageCell(ibe, imageBytes, column, colSpan);
            } catch (Exception e) {
                cell = new PdfPCell(new Phrase(IMAGE_NOT_LOADED));
            }
        }
    } else if (bandElement instanceof HyperlinkBandElement) {
        Hyperlink hyperlink = ((HyperlinkBandElement) bandElement).getHyperlink();
        Anchor anchor = new Anchor(hyperlink.getText(), fnt);
        anchor.setReference(hyperlink.getUrl());
        Phrase ph = new Phrase();
        ph.add(anchor);
        cell = new PdfPCell(ph);
    } else if (bandElement instanceof ReportBandElement) {
        Report report = ((ReportBandElement) bandElement).getReport();
        ExporterBean eb = null;
        try {
            eb = getSubreportExporterBean(report);
            PdfExporter subExporter = new PdfExporter(eb);
            subExporter.export();
            PdfPTable innerTable = subExporter.getTable();
            cell = new PdfPCell(innerTable);
        } catch (Exception e) {
            cell = new PdfPCell();
            e.printStackTrace();
        } finally {
            if ((eb != null) && (eb.getResult() != null)) {
                eb.getResult().close();
            }
        }
    } else if ((bandElement instanceof VariableBandElement) && (VariableFactory
            .getVariable(((VariableBandElement) bandElement).getVariable()) instanceof TotalPageNoVariable)) {
        try {
            cell = new PdfPCell(Image.getInstance(total));
        } catch (BadElementException e) {
            cell = new PdfPCell(new Phrase("NA"));
        }

    } else if (bandElement instanceof ImageColumnBandElement) {
        try {
            String v = StringUtil.getValueAsString(value, null);
            if (StringUtil.BLOB.equals(v)) {
                cell = new PdfPCell(new Phrase(StringUtil.BLOB));
            } else {
                byte[] bytes = StringUtil.decodeImage(v);
                cell = getImageCell(bandElement, bytes, column, colSpan);
            }
        } catch (Exception e) {
            e.printStackTrace();
            cell = new PdfPCell(new Phrase(IMAGE_NOT_LOADED));
        }
    } else {
        String stringValue;
        if (style.containsKey(StyleFormatConstants.PATTERN)) {
            stringValue = StringUtil.getValueAsString(value, (String) style.get(StyleFormatConstants.PATTERN),
                    getReportLanguage());
        } else {
            stringValue = StringUtil.getValueAsString(value, null, getReportLanguage());
        }
        if (stringValue == null) {
            stringValue = "";
        }
        if (stringValue.startsWith("<html>")) {
            StringReader reader = new StringReader(stringValue);
            List<Element> elems = new ArrayList<Element>();
            try {
                elems = HTMLWorker.parseToList(reader, new StyleSheet());
                Phrase ph = new Phrase();
                for (int i = 0; i < elems.size(); i++) {
                    Element elem = (Element) elems.get(i);
                    ph.add(elem);
                }
                cell = new PdfPCell(ph);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                Phrase ph = new Phrase(stringValue, fnt);
                cell = new PdfPCell(ph);
            }

        } else {
            Phrase ph = new Phrase(stringValue, fnt);
            cell = new PdfPCell(ph);
        }
    }

    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    cell.setUseDescender(true); // needed for a cell without padding
    cell.setMinimumHeight(MINIMUM_HEIGHT); // needed if there is a row in which all cells are empty

    if (bandElement != null) {
        cell.setRotation(bandElement.getTextRotation());
    }

    if (colSpan > 1) {
        cell.setColspan(colSpan);
    }

    if (rowSpan > 1) {
        cell.setRowspan(rowSpan);
    }

    if (style != null) {

        updateFont(style, fnt);

        if (style.containsKey(StyleFormatConstants.BACKGROUND_COLOR)) {
            Color val = (Color) style.get(StyleFormatConstants.BACKGROUND_COLOR);
            cell.setBackgroundColor(new BaseColor(val));
        }
        if (style.containsKey(StyleFormatConstants.HORIZONTAL_ALIGN_KEY)) {
            if (StyleFormatConstants.HORIZONTAL_ALIGN_LEFT
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            }
            if (StyleFormatConstants.HORIZONTAL_ALIGN_RIGHT
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            }
            if (StyleFormatConstants.HORIZONTAL_ALIGN_CENTER
                    .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) {
                cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            }
        }

        if (style.containsKey(StyleFormatConstants.VERTICAL_ALIGN_KEY)) {
            if (StyleFormatConstants.VERTICAL_ALIGN_TOP
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_TOP);
            }
            if (StyleFormatConstants.VERTICAL_ALIGN_MIDDLE
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            }
            if (StyleFormatConstants.VERTICAL_ALIGN_BOTTOM
                    .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) {
                cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
            }
        }

        if (style.containsKey(StyleFormatConstants.PADDING_LEFT)) {
            Float val = (Float) style.get(StyleFormatConstants.PADDING_LEFT);
            cell.setPaddingLeft(val);
        }
        if (style.containsKey(StyleFormatConstants.PADDING_RIGHT)) {
            Float val = (Float) style.get(StyleFormatConstants.PADDING_RIGHT);
            cell.setPaddingRight(val);
        }
        if (style.containsKey(StyleFormatConstants.PADDING_TOP)) {
            Float val = (Float) style.get(StyleFormatConstants.PADDING_TOP);
            cell.setPaddingTop(val);
        }
        if (style.containsKey(StyleFormatConstants.PADDING_BOTTOM)) {
            Float val = (Float) style.get(StyleFormatConstants.PADDING_BOTTOM);
            cell.setPaddingBottom(val);
        }
        cell.setBorderWidth(0);

        if (style.containsKey(StyleFormatConstants.BORDER_LEFT)) {
            Float val = (Float) style.get(StyleFormatConstants.BORDER_LEFT);
            cell.setBorderWidthLeft(val / 2);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_LEFT_COLOR);
            cell.setBorderColorLeft(new BaseColor(color));
        }
        if (style.containsKey(StyleFormatConstants.BORDER_RIGHT)) {
            Float val = (Float) style.get(StyleFormatConstants.BORDER_RIGHT);
            cell.setBorderWidthRight(val / 2);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_RIGHT_COLOR);
            cell.setBorderColorRight(new BaseColor(color));
        }
        if (style.containsKey(StyleFormatConstants.BORDER_TOP)) {
            Float val = (Float) style.get(StyleFormatConstants.BORDER_TOP);
            cell.setBorderWidthTop(val / 2);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_TOP_COLOR);
            cell.setBorderColorTop(new BaseColor(color));
        }
        if (style.containsKey(StyleFormatConstants.BORDER_BOTTOM)) {
            Float val = (Float) style.get(StyleFormatConstants.BORDER_BOTTOM);
            cell.setBorderWidthBottom(val / 2);
            Color color = (Color) style.get(StyleFormatConstants.BORDER_BOTTOM_COLOR);
            cell.setBorderColorBottom(new BaseColor(color));
        }

        // for subreports we use default no wrap
        if (cell.getTable() == null) {
            cell.setNoWrap(true);
            if (bandElement != null) {
                if (bandElement.isWrapText()) {
                    cell.setNoWrap(false);
                }
            }
        }

        // to see a background image all cells must not have any background!
        if (bean.getReportLayout().getBackgroundImage() != null) {
            cell.setBackgroundColor(null);
        }
    }
    return cell;
}