Package com.lowagie.text

Examples of com.lowagie.text.Cell


   * Creates a Cell object based on a list of properties.
   * @param attributes
   * @return a Cell
   */
  public static Cell getCell(Properties attributes) {
    Cell cell = new Cell();
    String value;

    cell.setHorizontalAlignment(attributes
        .getProperty(ElementTags.HORIZONTALALIGN));
    cell.setVerticalAlignment(attributes
        .getProperty(ElementTags.VERTICALALIGN));

    value = attributes.getProperty(ElementTags.WIDTH);
    if (value != null) {
      cell.setWidth(value);
    }
    value = attributes.getProperty(ElementTags.COLSPAN);
    if (value != null) {
      cell.setColspan(Integer.parseInt(value));
    }
    value = attributes.getProperty(ElementTags.ROWSPAN);
    if (value != null) {
      cell.setRowspan(Integer.parseInt(value));
    }
    value = attributes.getProperty(ElementTags.LEADING);
    if (value != null) {
      cell.setLeading(Float.parseFloat(value + "f"));
    }
    cell.setHeader(Utilities.checkTrueOrFalse(attributes,
        ElementTags.HEADER));
    if (Utilities.checkTrueOrFalse(attributes, ElementTags.NOWRAP)) {
      cell.setMaxLines(1);
    }
    setRectangleProperties(cell, attributes);
    return cell;
  }
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

          new FileOutputStream("imageTable.pdf"));
      // step 3: we open the document
      document.open();
      // step 4: we create a table and add it to the document
      Table table = new Table(2, 2); // 2 rows, 2 columns
      table.addCell(new Cell(Image.getInstance("otsoe.jpg")));
      table.addCell(new Cell(Image.getInstance("iText.gif")));
      Cell c1 = new Cell();
      c1.add(Image.getInstance("iText.gif"));
      table.addCell(c1);
      Cell c2 = new Cell();
      c2.add(Image.getInstance("otsoe.jpg"));
      table.addCell(c2);
      document.add(table);
      document.add(new Paragraph("converted to PdfPTable:"));
      table.setConvert2pdfptable(true);
      document.add(table);
View Full Code Here

            // step 4: we create a table and add it to the document
            Table table = new Table(3);
            table.setBorderWidth(1);
            table.setBorderColor(new Color(0, 0, 255));
            table.setPadding(10);
            Cell cell = new Cell("header");
            cell.setHeader(true);
            cell.setColspan(3);
            table.addCell(cell);
            table.addCell("1.1");
            table.addCell("2.1");
            table.addCell("3.1");
            table.addCell("1.2");
            table.addCell("2.2");
            table.addCell("3.2");
            document.add(table);
            table.setConvert2pdfptable(true);
      document.add(new Paragraph("converted to PdfPTable:"));
            document.add(table);
           
            table = new Table(3);
            table.setBorderWidth(3);
            table.setBorderColor(new Color(255, 0, 0));
            table.setPadding(0);
            cell = new Cell("header");
            cell.setHeader(true);
            cell.setBorderColorBottom(new Color(0, 0, 255));
            cell.setColspan(3);
            table.addCell(cell);
            table.addCell("1.1");
            cell = new Cell("2.1");
            cell.setBorderWidthLeft(4);
            cell.setBorderWidthRight(8);
            cell.setBorderWidthTop(2);
            cell.setBorderWidthBottom(10);
            cell.setUseBorderPadding(true);
            cell.setBorderColorBottom(new Color(0, 255, 0));
            table.addCell(cell);
            table.addCell("3.1");
            table.addCell("1.2");
            table.addCell("2.2");
            table.addCell("3.2");
View Full Code Here

            datatable.setWidths(headerwidths);
            datatable.setWidth(100);
            datatable.setPadding(3);
           
            // the first cell spans 10 columns
            Cell cell = new Cell(new Phrase("Administration -System Users Report", FontFactory.getFont(FontFactory.HELVETICA, 24, Font.BOLD)));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setLeading(30);
            cell.setColspan(10);
            cell.setBorder(Rectangle.NO_BORDER);
            cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0));
            datatable.addCell(cell);
           
            // These cells span 2 rows
            datatable.getDefaultCell().setBorderWidth(2);
            datatable.getDefaultCell().setHorizontalAlignment(1);
View Full Code Here

            Table table = new Table(3);
            table.setBorderWidth(1);
            table.setBorderColor(new Color(0, 0, 255));
            table.setPadding(5);
            table.setSpacing(5);
            Cell cell = new Cell("header");
            cell.setHeader(true);
            cell.setColspan(3);
            table.addCell(cell);
            cell = new Cell("example cell with colspan 1 and rowspan 2");
            cell.setRowspan(2);
            cell.setBorderColor(new Color(255, 0, 0));
            table.addCell(cell);
            table.addCell("1.1");
            table.addCell("2.1");
            table.addCell("1.2");
            table.addCell("2.2");
            table.addCell("cell test1");
            cell = new Cell("big cell");
            cell.setRowspan(2);
            cell.setColspan(2);
            cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0));
            table.addCell(cell);
            table.addCell("cell test2");
            document.add(table);
        }
        catch(DocumentException de) {
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];
                            cellNulls[j] = false;
                        } 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

            Table table = new Table(3);
            table.setPadding(2);
            table.setAlignment(Element.ALIGN_LEFT);
            table.setSpacing(2);

            Cell emptyCell = new Cell("");

            Cell cellLeft = new Cell("Left Alignment");
            cellLeft.setHorizontalAlignment(Element.ALIGN_LEFT);
            Cell cellCenter = new Cell("Center Alignment");
            cellCenter.setHorizontalAlignment(Element.ALIGN_CENTER);
            Cell cellRight = new Cell("Right Alignment");
            cellRight.setHorizontalAlignment(Element.ALIGN_RIGHT);

            table.addCell(cellLeft);
            table.addCell(cellCenter);
            table.addCell(cellRight);

            Cell cellSpanHoriz = new Cell("This Cell spans two columns");
            cellSpanHoriz.setColspan(2);
            table.addCell(cellSpanHoriz);
            table.addCell(emptyCell);

            Cell cellSpanVert = new Cell("This Cell spans two rows");
            cellSpanVert.setRowspan(2);
            table.addCell(emptyCell);
            table.addCell(cellSpanVert);
            table.addCell(emptyCell);
            table.addCell(emptyCell);
            table.addCell(emptyCell);

            Cell cellSpanHorizVert = new Cell(
                    "This Cell spans both two columns and two rows");
            cellSpanHorizVert.setColspan(2);
            cellSpanHorizVert.setRowspan(2);
            table.addCell(emptyCell);
            table.addCell(cellSpanHorizVert);
            table.addCell(emptyCell);

            RtfCell cellDotted = new RtfCell("Dotted border");
View Full Code Here

            // Create the table that will be used as the footer
            Table footer = new Table(2);
            footer.setBorder(0);
            footer.getDefaultCell().setBorder(0);
            footer.setWidth(100);
            footer.addCell(new Cell("(c) Mark Hall"));
            Paragraph pageNumber = new Paragraph("Page ");
           
            // The RtfPageNumber is an RTF specific element that adds a page number field
            pageNumber.add(new RtfPageNumber());
            pageNumber.setAlignment(Paragraph.ALIGN_RIGHT);
            footer.addCell(new Cell(pageNumber));
           
            // Create the RtfHeaderFooter and set it as the footer to use
            document.setFooter(new RtfHeaderFooter(footer));
           
            document.open();
View Full Code Here

            description = " - ";
        }

        Table table = newTable();

        Cell headerCell = newHeaderCell( "Description",
                                         CATEGORIES_TEXT );
        table.addCell( headerCell );

        table.addCell( newCell( description ) );
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.