예제 #1
0
 /**
  * Constructs a deep copy of a <CODE>PdfPCell</CODE>.
  *
  * @param cell the <CODE>PdfPCell</CODE> to duplicate
  */
 public PdfPCell(PdfPCell cell) {
   super(cell.llx, cell.lly, cell.urx, cell.ury);
   cloneNonPositionParameters(cell);
   verticalAlignment = cell.verticalAlignment;
   paddingLeft = cell.paddingLeft;
   paddingRight = cell.paddingRight;
   paddingTop = cell.paddingTop;
   paddingBottom = cell.paddingBottom;
   phrase = cell.phrase;
   fixedHeight = cell.fixedHeight;
   minimumHeight = cell.minimumHeight;
   noWrap = cell.noWrap;
   colspan = cell.colspan;
   rowspan = cell.rowspan;
   if (cell.table != null) table = new PdfPTable(cell.table);
   image = Image.getInstance(cell.image);
   cellEvent = cell.cellEvent;
   useDescender = cell.useDescender;
   column = ColumnText.duplicate(cell.column);
   useBorderPadding = cell.useBorderPadding;
   rotation = cell.rotation;
   id = cell.id;
   role = cell.role;
   if (cell.accessibleAttributes != null)
     accessibleAttributes = new HashMap<PdfName, PdfObject>(cell.accessibleAttributes);
   headers = cell.headers;
 }
예제 #2
0
 /**
  * Returns the height of the cell.
  *
  * @return the height of the cell
  * @since 3.0.0
  */
 public float getMaxHeight() {
   boolean pivoted = getRotation() == 90 || getRotation() == 270;
   Image img = getImage();
   if (img != null) {
     img.scalePercent(100);
     float refWidth = pivoted ? img.getScaledHeight() : img.getScaledWidth();
     float scale =
         (getRight() - getEffectivePaddingRight() - getEffectivePaddingLeft() - getLeft())
             / refWidth;
     img.scalePercent(scale * 100);
     float refHeight = pivoted ? img.getScaledWidth() : img.getScaledHeight();
     setBottom(getTop() - getEffectivePaddingTop() - getEffectivePaddingBottom() - refHeight);
   } else {
     if ((pivoted && hasFixedHeight()) || getColumn() == null)
       setBottom(getTop() - getFixedHeight());
     else {
       ColumnText ct = ColumnText.duplicate(getColumn());
       float right, top, left, bottom;
       if (pivoted) {
         right = PdfPRow.RIGHT_LIMIT;
         top = getRight() - getEffectivePaddingRight();
         left = 0;
         bottom = getLeft() + getEffectivePaddingLeft();
       } else {
         right = isNoWrap() ? PdfPRow.RIGHT_LIMIT : getRight() - getEffectivePaddingRight();
         top = getTop() - getEffectivePaddingTop();
         left = getLeft() + getEffectivePaddingLeft();
         bottom =
             hasFixedHeight()
                 ? getTop() + getEffectivePaddingBottom() - getFixedHeight()
                 : PdfPRow.BOTTOM_LIMIT;
       }
       PdfPRow.setColumn(ct, left, bottom, right, top);
       try {
         ct.go(true);
       } catch (DocumentException e) {
         throw new ExceptionConverter(e);
       }
       if (pivoted)
         setBottom(
             getTop()
                 - getEffectivePaddingTop()
                 - getEffectivePaddingBottom()
                 - ct.getFilledWidth());
       else {
         float yLine = ct.getYLine();
         if (isUseDescender()) yLine += ct.getDescender();
         setBottom(yLine - getEffectivePaddingBottom());
       }
     }
   }
   float height = getHeight();
   if (height == getEffectivePaddingTop() + getEffectivePaddingBottom()) height = 0;
   if (hasFixedHeight()) height = getFixedHeight();
   else if (hasMinimumHeight() && height < getMinimumHeight()) height = getMinimumHeight();
   return height;
 }