1 Reply Latest reply on Apr 20, 2008 10:02 PM by Richard Leherpeur

    PDF: Image inside a cell cannot be aligned properly

    Richard Leherpeur Newbie

      I noticed that this is not possible to properly align an image inside a cell.
      I investigated a little and found out that one case is missing the UICell.handleAdd method.


      The actual method is implemented as:



          public void handleAdd(Object o) {
                if (o instanceof Phrase) {
                    cell.setPhrase((Phrase) o);
                } else if (o instanceof Element) {
                  // calling addElement negates setPhrase, etc...
                  cell.addElement((Element) o);
              } else {
                  throw new RuntimeException("Can't add " + o.getClass().getName() + " to cell");
              }
          }
      



      The correct implementation should be:



          public void handleAdd(Object o) {
                if (o instanceof Phrase) {
                    cell.setPhrase((Phrase) o);
                } else if (o instanceof Image) {
                    // Allow proper control over image alignment
                          cell.setImage((Image) o);
                } else if (o instanceof Element) {
                  // calling addElement negates setPhrase, etc...
                  cell.addElement((Element) o);
              } else {
                  throw new RuntimeException("Can't add " + o.getClass().getName() + " to cell");
              }
          }