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

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

Introduction

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

Prototype

public void setRotation(int rotation) 

Source Link

Document

Sets the rotation of the cell.

Usage

From source file:com.softwaremagico.tm.pdf.complete.elements.LateralHeaderPdfPTable.java

License:Open Source License

protected PdfPCell createLateralVerticalTitle(String title, int rowspan) {
    Font font = new Font(FadingSunsTheme.getTitleFont(), getTitleFontSize());
    font.setColor(BaseColor.WHITE);/*w w w . ja v  a 2  s .  c o m*/
    Phrase content = new Phrase(title, font);
    PdfPCell titleCell = new PdfPCell(content);
    titleCell.setPadding(0);
    titleCell.setRowspan(rowspan);
    titleCell.setRotation(90);
    titleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    // titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    titleCell.setBackgroundColor(BaseColor.BLACK);
    return titleCell;
}

From source file:com.softwaremagico.tm.pdf.complete.skills.WyrdTable.java

License:Open Source License

@Override
protected PdfPCell createLateralVerticalTitle(String title, int rowspan) {
    PdfPCell titleCell = super.createLateralVerticalTitle(title, rowspan);
    titleCell.setRotation(270);
    return titleCell;
}

From source file:com.vectorprint.report.itext.style.stylers.Rotation.java

License:Open Source License

@Override
public <E> E style(E text, Object data) throws VectorPrintException {
    PdfPCell cell = (PdfPCell) text;

    cell.setRotation(getRotation());

    return text;/*from   w w w  .  ja v  a2 s .  c o m*/
}

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

License:Open Source License

/**
 * //from w  w w  .ja v a2s . 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:fll.web.playoff.ScoresheetGenerator.java

License:Open Source License

/**
 * Stores the goal cells that are inserted into the output after the team name
 * headers and before the scoring/initials blanks at the bottom of the
 * scoresheet.//from  ww w  . j av a  2  s  .c  o m
 */
private void setChallengeInfo(final ChallengeDescription description) {
    setPageTitle(description.getTitle());

    if (null != description.getRevision()) {
        setRevisionInfo(description.getRevision());
    }

    if (null != description.getCopyright()) {
        m_copyright = description.getCopyright();
    } else {
        m_copyright = null;
    }

    final PerformanceScoreCategory performanceElement = description.getPerformance();
    // use ArrayList as we will be doing indexed access in the loop
    final List<AbstractGoal> goals = new ArrayList<>(performanceElement.getGoals());

    final float[] relativeWidths = new float[3];
    relativeWidths[0] = 4;
    relativeWidths[1] = 48;
    relativeWidths[2] = 48;
    m_goalsTable = new PdfPTable(relativeWidths);

    String prevCategory = null;
    for (int goalIndex = 0; goalIndex < goals.size(); ++goalIndex) {
        final AbstractGoal goal = goals.get(goalIndex);
        if (!goal.isComputed()) {
            final String category = goal.getCategory();

            // add category cell if needed
            boolean firstRowInCategory = false;
            if (!StringUtils.equals(prevCategory, category)) {
                if (!StringUtils.isEmpty(category)) {

                    // find out how many future goals have the same category
                    int categoryRowSpan = 1;
                    for (int otherIndex = goalIndex + 1; otherIndex < goals.size(); ++otherIndex) {
                        final AbstractGoal otherGoal = goals.get(otherIndex);
                        if (!otherGoal.isComputed()) {
                            if (StringUtils.equals(category, otherGoal.getCategory())) {
                                ++categoryRowSpan;
                            } else {
                                break;
                            }
                        }
                    }

                    final Paragraph catPara = new Paragraph(category, ARIAL_10PT_NORMAL);
                    final PdfPCell categoryCell = new PdfPCell(catPara);
                    categoryCell.setBorderWidthTop(1);
                    categoryCell.setBorderWidthBottom(0);
                    categoryCell.setBorderWidthLeft(0);
                    categoryCell.setBorderWidthRight(0);
                    categoryCell.setVerticalAlignment(Element.ALIGN_CENTER);
                    categoryCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    categoryCell.setRotation(90);
                    categoryCell.setRowspan(categoryRowSpan);
                    m_goalsTable.addCell(categoryCell);
                }

                // first row in a new category, which may be empty
                firstRowInCategory = true;
            }

            // This is the text for the left hand "label" cell
            final String title = goal.getTitle();
            final Paragraph p = new Paragraph(title, ARIAL_10PT_NORMAL);
            final PdfPCell goalLabel = new PdfPCell(p);
            goalLabel.setHorizontalAlignment(Element.ALIGN_RIGHT);
            goalLabel.setVerticalAlignment(Element.ALIGN_CENTER);
            if (firstRowInCategory) {
                goalLabel.setBorderWidthTop(1);
                goalLabel.setBorderWidthBottom(0);
                goalLabel.setBorderWidthLeft(0);
                goalLabel.setBorderWidthRight(0);
            } else {
                goalLabel.setBorder(0);
            }
            goalLabel.setPaddingRight(9);
            goalLabel.setVerticalAlignment(Element.ALIGN_TOP);
            if (StringUtils.isEmpty(category)) {
                // category column and goal label column
                goalLabel.setColspan(2);
            }
            m_goalsTable.addCell(goalLabel);

            // define the value cell
            final double min = goal.getMin();
            final String minStr = FP.equals(min, Math.round(min), 1E-6) ? String.valueOf((int) min)
                    : String.valueOf(min);
            final double max = goal.getMax();
            final String maxStr = FP.equals(max, Math.round(max), 1E-6) ? String.valueOf((int) max)
                    : String.valueOf(max);

            // If element has child nodes, then we have an enumerated list
            // of choices. Otherwise it is either yes/no or a numeric field.
            final PdfPCell goalValue = new PdfPCell();
            final Chunk choices = new Chunk("", COURIER_10PT_NORMAL);
            if (goal.isEnumerated()) {
                // replace spaces with "no-break" spaces
                boolean first = true;
                final List<EnumeratedValue> values = goal.getSortedValues();
                for (final EnumeratedValue value : values) {
                    if (!first) {
                        choices.append(" /" + Utilities.NON_BREAKING_SPACE);
                    } else {
                        first = false;
                    }
                    choices.append(value.getTitle().toUpperCase().replace(' ', Utilities.NON_BREAKING_SPACE));
                }
                goalValue.addElement(choices);

            } else {
                if (goal.isYesNo()) {
                    // order of yes/no needs to match ScoreEntry.generateYesNoButtons
                    final Paragraph q = new Paragraph("NO / YES", COURIER_10PT_NORMAL);
                    goalValue.addElement(q);

                } else {
                    final String range = "(" + minStr + " - " + maxStr + ")";
                    final PdfPTable t = new PdfPTable(2);
                    t.setHorizontalAlignment(Element.ALIGN_LEFT);
                    t.setTotalWidth(1 * POINTS_PER_INCH);
                    t.setLockedWidth(true);
                    final Phrase r = new Phrase("", ARIAL_8PT_NORMAL);
                    t.addCell(new PdfPCell(r));
                    final Phrase q = new Phrase(range, ARIAL_8PT_NORMAL);
                    t.addCell(new PdfPCell(q));
                    goalValue.setPaddingTop(9);
                    goalValue.addElement(t);
                }
            }

            if (firstRowInCategory) {
                goalValue.setBorderWidthTop(1);
                goalValue.setBorderWidthBottom(0);
                goalValue.setBorderWidthLeft(0);
                goalValue.setBorderWidthRight(0);
            } else {
                goalValue.setBorder(0);
            }
            goalValue.setVerticalAlignment(Element.ALIGN_MIDDLE);

            m_goalsTable.addCell(goalValue);

            // setup for next loop
            prevCategory = category;
        } // if not computed goal

    } // foreach goal

}

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 ww.  ja  v  a2 s  .  c om*/
        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);/*from   ww  w  .j  av  a 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: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;/*from w w w  .  jav a2 s .  c  om*/
    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;
}

From source file:se.billes.pdf.renderer.request.factory.CellFactory.java

License:Open Source License

public PdfPCell createCell(Block block) {
    float[] margins = block.getMargins();
    PdfPCell cell = new PdfPCell();
    cell.setBorderWidth(0);/*  w  w  w .  ja v  a2  s. c  o  m*/
    cell.setVerticalAlignment(VerticalAlign.getByName(block.getVerticalAlign()).getAlignment());
    cell.setLeft(0);
    cell.setTop(0);
    cell.setRight(0);
    cell.setBottom(0);
    cell.setUseAscender(block.isUseAscender());
    cell.setIndent(0);
    cell.setPaddingLeft(SizeFactory.millimetersToPostscriptPoints(margins[0]));
    cell.setPaddingBottom(SizeFactory.millimetersToPostscriptPoints(margins[3]));
    cell.setPaddingRight(SizeFactory.millimetersToPostscriptPoints(margins[1]));
    cell.setPaddingTop(SizeFactory.millimetersToPostscriptPoints(margins[2]));
    cell.setFixedHeight(SizeFactory.millimetersToPostscriptPoints(block.getPosition()[3]));
    cell.setBorder(0);
    cell.setCellEvent(new CellBlockEvent().createEvent(block));
    cell.setRotation(block.getRotation());
    return cell;
}