Package com.lowagie.text

Examples of com.lowagie.text.Cell


                Column column = columnIterator.nextColumn();

                // Get the value to be displayed for the column
                Object value = column.getValue(this.decorated);

                Cell cell = getCell(ObjectUtils.toString(value));
                tablePDF.addCell(cell);
            }
        }
    }
View Full Code Here


     * @return Cell
     * @throws BadElementException errors while generating content
     */
    private Cell getCell(String value) throws BadElementException
    {
        Cell cell = new Cell(new Chunk(StringUtils.trimToEmpty(value), smallFont));
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setLeading(8);
        return cell;
    }
View Full Code Here

            if (columnHeader == null)
            {
                columnHeader = StringUtils.capitalize(headerCell.getBeanPropertyName());
            }

            Cell hdrCell = this.getHeaderCell(columnHeader);
            this.table.addCell(hdrCell);
        }
        this.table.setWidths(widths);
        this.table.endHeaders();
    }
View Full Code Here

     */
    protected void writePostBodyFooter(TableModel model) throws DocumentException
    {
        Chunk cellContent = new Chunk(model.getFooter(), this.getFooterFont());
        this.setFooterFontStyle(cellContent);
        Cell cell = new Cell(cellContent);
        cell.setLeading(8);
        cell.setBackgroundColor(this.getFooterBackgroundColor());
        cell.setHorizontalAlignment(this.getFooterHorizontalAlignment());
        cell.setColspan(model.getNumberOfColumns());
        table.addCell(cell);
    }
View Full Code Here

     * @return Cell
     * @throws BadElementException if errors occurs while generating content.
     */
    private Cell getCell(Object value) throws BadElementException
    {
        Cell cell = new Cell(new Chunk(StringUtils.trimToEmpty(ObjectUtils.toString(value)), this.defaultFont));
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        cell.setLeading(8);
        return cell;
    }
View Full Code Here

     */
    private Cell getHeaderCell(String value) throws BadElementException
    {
        Chunk cellContent = new Chunk(value, this.getHeaderFont());
        setHeaderFontStyle(cellContent);
        Cell cell = new Cell(cellContent);
        cell.setLeading(8);
        cell.setHeader(true);
        cell.setHorizontalAlignment(this.getHeaderHorizontalAlignment());
        cell.setBackgroundColor(this.getHeaderBackgroundColor());
        return cell;
    }
View Full Code Here

       
       
        for (int i=0; i<slt.getRowCount(); i++){
           
            ServiceItem si = (ServiceItem) slt.getServiceItem(i);
            Cell c;

            // Start time
            c = new Cell(si.getStartTime());
            c.setMaxLines(1);
            c.setVerticalAlignment(Cell.ALIGN_MIDDLE);
            c.setHorizontalAlignment(Cell.ALIGN_CENTER);
            t.addCell(c);
           
            // Duration
            c = new Cell(Integer.toString(si.getDuration()));
            c.setMaxLines(1);
            c.setVerticalAlignment(Cell.ALIGN_MIDDLE);
            c.setHorizontalAlignment(Cell.ALIGN_RIGHT);
            t.addCell(c);
           
            // Title
            c = new Cell(si.getTitle());
            c.setVerticalAlignment(Cell.ALIGN_MIDDLE);
            t.addCell(c);

            // Notes
            c = new Cell(si.getNotes());
            c.setVerticalAlignment(Cell.ALIGN_MIDDLE);
            t.addCell(c);

        }
       
        document.add(t);
View Full Code Here

    }
   
   
    private Cell createHeaderCell(String text) throws BadElementException{

        Cell c = new Cell(new Chunk(text,FontFactory.getFont(FontFactory.HELVETICA_BOLD) ));
        c.setMaxLines(1);
        c.setHeader(true);
        c.setVerticalAlignment(Cell.ALIGN_MIDDLE);
        c.setHorizontalAlignment(Cell.ALIGN_CENTER);
        return c;

    }
View Full Code Here

                currentfont.pop();
                return;
            }
            case Element.CELL:
            {
                Cell cell = (Cell) element;
               
                // start tag
                addTabs(indent);
                if (cell.isHeader()) {
                    writeStart(HtmlTags.HEADERCELL);
                }
                else {
                    writeStart(HtmlTags.CELL);
                }
                writeMarkupAttributes(markup);
                if (cell.getBorderWidth() != Rectangle.UNDEFINED) {
                    write(HtmlTags.BORDERWIDTH, String.valueOf(cell.getBorderWidth()));
                }
                if (cell.getBorderColor() != null) {
                    write(HtmlTags.BORDERCOLOR, HtmlEncoder.encode(cell.getBorderColor()));
                }
                if (cell.getBackgroundColor() != null) {
                    write(HtmlTags.BACKGROUNDCOLOR, HtmlEncoder.encode(cell.getBackgroundColor()));
                }
                String alignment = HtmlEncoder.getAlignment(cell.getHorizontalAlignment());
                if (!"".equals(alignment)) {
                    write(HtmlTags.HORIZONTALALIGN, alignment);
                }
                alignment = HtmlEncoder.getAlignment(cell.getVerticalAlignment());
                if (!"".equals(alignment)) {
                    write(HtmlTags.VERTICALALIGN, alignment);
                }
                if (cell.getWidthAsString() != null) {
                    write(HtmlTags.WIDTH, cell.getWidthAsString());
                }
                if (cell.getColspan() != 1) {
                    write(HtmlTags.COLSPAN, String.valueOf(cell.getColspan()));
                }
                if (cell.getRowspan() != 1) {
                    write(HtmlTags.ROWSPAN, String.valueOf(cell.getRowspan()));
                }
                if (cell.getMaxLines() == 1) {
                  write(HtmlTags.STYLE, "white-space: nowrap;");
                }
                os.write(GT);
                // contents
                if (cell.isEmpty()) {
                    write(NBSP);
                } else {
                    for (Iterator i = cell.getElements(); i.hasNext(); ) {
                        write((Element) i.next(), indent + 1);
                    }
                }
                // end tag
                addTabs(indent);
                if (cell.isHeader()) {
                    writeEnd(HtmlTags.HEADERCELL);
                }
                else {
                    writeEnd(HtmlTags.CELL);
                }
View Full Code Here

            // rows
            if (ElementTags.ROW.equals(name)) {
                ArrayList cells = new ArrayList();
                int columns = 0;
                Table table;
                Cell cell;
                while (true) {
                    Element element = (Element) stack.pop();
                    if (element.type() == Element.CELL) {
                        cell = (Cell) element;
                        columns += cell.getColspan();
                        cells.add(cell);
                    } else {
                        table = (Table) element;
                        break;
                    }
                }
                if (table.getColumns() < columns) {
                    table.addColumns(columns - table.getColumns());
                }
                Collections.reverse(cells);
                String width;
                float[] cellWidths = new float[columns];
                boolean[] cellNulls = new boolean[columns];
                for (int i = 0; i < columns; i++) {
                    cellWidths[i] = 0;
                    cellNulls[i] = true;
                }
                float total = 0;
                int j = 0;
                for (Iterator i = cells.iterator(); i.hasNext();) {
                    cell = (Cell) i.next();
                    width = cell.getWidthAsString();
                    if (cell.getWidth() == 0) {
                        if (cell.getColspan() == 1 && cellWidths[j] == 0) {
                            try {
                                cellWidths[j] = 100f / columns;
                                total += cellWidths[j];
                            } catch (Exception e) {
                                // empty on purpose
                            }
                        } else if (cell.getColspan() == 1) {
                            cellNulls[j] = false;
                        }
                    } else if (cell.getColspan() == 1 && width.endsWith("%")) {
                        try {
                            cellWidths[j] = Float.parseFloat(
                                    width.substring(0, width.length() - 1)
                                            + "f");
                            total += cellWidths[j];
                        } catch (Exception e) {
                            // empty on purpose
                        }
                    }
                    j += cell.getColspan();
                    table.addCell(cell);
                }
                float widths[] = table.getProportionalWidths();
                if (widths.length == columns) {
                    float left = 0.0f;
View Full Code Here

TOP

Related Classes of com.lowagie.text.Cell

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.