Examples of LwgCell


Examples of com.lowagie.text.LwgCell

                currentfont.pop();
                return;
            }
            case LwgElement.CELL:
            {
                LwgCell cell = (LwgCell) element;
               
                // start tag
                addTabs(indent);
                if (cell.isHeader()) {
                    writeStart(HtmlTags.HEADERCELL);
                }
                else {
                    writeStart(HtmlTags.CELL);
                }
                writeMarkupAttributes(markup);
                if (cell.getBorderWidth() != LwgRectangle.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((LwgElement) i.next(), indent + 1);
                    }
                }
                // end tag
                addTabs(indent);
                if (cell.isHeader()) {
                    writeEnd(HtmlTags.HEADERCELL);
                }
                else {
                    writeEnd(HtmlTags.CELL);
                }
View Full Code Here

Examples of com.lowagie.text.LwgCell

            // rows
            if (ElementTags.ROW.equals(name)) {
                ArrayList cells = new ArrayList();
                int columns = 0;
                Table table;
                LwgCell cell;
                while (true) {
                    LwgElement element = (LwgElement) stack.pop();
                    if (element.type() == LwgElement.CELL) {
                        cell = (LwgCell) 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 = (LwgCell) 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

Examples of com.lowagie.text.LwgCell

        int cellWidth = 0;
        for(int i = 0; i < row.getColumns(); i++) {
            cellWidth = (int) (this.width * this.parentTable.getProportionalWidths()[i] / 100);
            cellRight = cellRight + cellWidth;
           
            LwgCell cell = (LwgCell) row.getCell(i);
            RtfCell rtfCell = new RtfCell(this.document, this, cell);
            rtfCell.setCellRight(cellRight);
            rtfCell.setCellWidth(cellWidth);
            this.cells.add(rtfCell);
        }
View Full Code Here

Examples of com.lowagie.text.LwgCell

            // 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);
            LwgCell cell = new LwgCell("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 LwgCell("header");
            cell.setHeader(true);
            cell.setBorderColorBottom(new Color(0, 0, 255));
            cell.setColspan(3);
            table.addCell(cell);
            table.addCell("1.1");
            cell = new LwgCell("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

Examples of com.lowagie.text.LwgCell

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

            LwgCell emptyCell = new LwgCell("");

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

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

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

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

            LwgCell cellSpanHorizVert = new LwgCell(
                    "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

Examples of com.lowagie.text.LwgCell

            // 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 LwgCell("(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 LwgCell(pageNumber));
           
            // Create the RtfHeaderFooter and set it as the footer to use
            document.setFooter(new RtfHeaderFooter(footer));
           
            document.open();
View Full Code Here

Examples of com.lowagie.text.LwgCell

            datatable.setWidths(headerwidths);
            datatable.setWidth(100);
            datatable.setPadding(3);
           
            // the first cell spans 10 columns
            LwgCell cell = new LwgCell(new LwgPhrase("Administration -System Users Report", FontFactory.getFont(FontFactory.HELVETICA, 24, LwgFont.BOLD)));
            cell.setHorizontalAlignment(LwgElement.ALIGN_CENTER);
            cell.setLeading(30);
            cell.setColspan(10);
            cell.setBorder(LwgRectangle.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

Examples of com.lowagie.text.LwgCell

   * Creates a LwgCell object based on a list of properties.
   * @param attributes
   * @return a LwgCell
   */
  public static LwgCell getCell(Properties attributes) {
    LwgCell cell = new LwgCell();
    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

Examples of com.lowagie.text.LwgCell

    int prevRows = rows();
    int rowNumber = 0;
    int groupNumber = 0;
    boolean groupChange;
    int firstDataRow = table.getLastHeaderRow() + 1;
    LwgCell cell;
    PdfCell currentCell;
    ArrayList newCells = new ArrayList();
    int rows = table.size() + 1;
    float[] offsets = new float[rows];
    for (int i = 0; i < rows; i++) {
      offsets[i] = getBottom();
    }
       
    // loop over all the rows
    for (Iterator rowIterator = table.iterator(); rowIterator.hasNext(); ) {
      groupChange = false;
      row = (LwgRow) rowIterator.next();
      if (row.isEmpty()) {
        if (rowNumber < rows - 1 && offsets[rowNumber + 1] > offsets[rowNumber]) offsets[rowNumber + 1] = offsets[rowNumber];
      }
      else {
        for(int i = 0; i < row.getColumns(); i++) {
          cell = (LwgCell) row.getCell(i);
          if (cell != null) {
            currentCell = new PdfCell(cell, rowNumber+prevRows, positions[i], positions[i + cell.getColspan()], offsets[rowNumber], cellspacing(), cellpadding());
            if (rowNumber < firstDataRow) {
              currentCell.setHeader();
              headercells.add(currentCell);
              if (!table.isNotAddedYet())
                continue;
            }
            try {
              if (offsets[rowNumber] - currentCell.getHeight() - cellpadding() < offsets[rowNumber + currentCell.rowspan()]) {
                offsets[rowNumber + currentCell.rowspan()] = offsets[rowNumber] - currentCell.getHeight() - cellpadding();
              }
            }
            catch(ArrayIndexOutOfBoundsException aioobe) {
              if (offsets[rowNumber] - currentCell.getHeight() < offsets[rows - 1]) {
                offsets[rows - 1] = offsets[rowNumber] - currentCell.getHeight();
              }
            }
            currentCell.setGroupNumber(groupNumber);
            groupChange |= cell.getGroupChange();
            newCells.add(currentCell);
          }
        }
      }
      rowNumber++;
View Full Code Here

Examples of com.lowagie.text.LwgCell

          new GfrFileOutputStream("com.lowagie.examples.objects.tables.alternatives.TableWithImage.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 LwgCell(LwgImage.getInstance("otsoe.jpg")));
      table.addCell(new LwgCell(LwgImage.getInstance("iText.gif")));
      LwgCell c1 = new LwgCell();
      c1.add(LwgImage.getInstance("iText.gif"));
      table.addCell(c1);
      LwgCell c2 = new LwgCell();
      c2.add(LwgImage.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
TOP
Copyright © 2018 www.massapi.com. 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.