/**
  * Constructs a <CODE>PdfPCell</CODE> with a <CODE>Phrase</CODE>. The default padding is 2.
  *
  * @param phrase the text
  */
 public PdfPCell(Phrase phrase) {
   super(0, 0, 0, 0);
   borderWidth = 0.5f;
   border = BOX;
   column.addText(this.phrase = phrase);
   column.setLeading(0, 1);
 }
Beispiel #2
0
 /**
  * Constructs a <CODE>PdfPCell</CODE> with a <CODE>PdfPtable</CODE>. This constructor allows
  * nested tables.
  *
  * @param table The <CODE>PdfPTable</CODE>
  * @param style The style to apply to the cell (you could use getDefaultCell())
  * @since 2.1.0
  */
 public PdfPCell(PdfPTable table, PdfPCell style) {
   super(0, 0, 0, 0);
   borderWidth = 0.5f;
   border = BOX;
   column.setLeading(0, 1);
   this.table = table;
   table.setWidthPercentage(100);
   table.setExtendLastRow(true);
   column.addElement(table);
   if (style != null) {
     cloneNonPositionParameters(style);
     verticalAlignment = style.verticalAlignment;
     paddingLeft = style.paddingLeft;
     paddingRight = style.paddingRight;
     paddingTop = style.paddingTop;
     paddingBottom = style.paddingBottom;
     colspan = style.colspan;
     rowspan = style.rowspan;
     cellEvent = style.cellEvent;
     useDescender = style.useDescender;
     useBorderPadding = style.useBorderPadding;
     rotation = style.rotation;
   } else {
     setPadding(0);
   }
 }
 void setTable(PdfPTable table) {
   this.table = table;
   column.setText(null);
   image = null;
   if (table != null) {
     table.setExtendLastRow(verticalAlignment == Element.ALIGN_TOP);
     column.addElement(table);
     table.setWidthPercentage(100);
   }
 }
 /**
  * Constructs a <CODE>PdfPCell</CODE> with an <CODE>Image</CODE>. The default padding is 0.25 for
  * a border width of 0.5.
  *
  * @param image the <CODE>Image</CODE>
  * @param fit <CODE>true</CODE> to fit the image to the cell
  */
 public PdfPCell(Image image, boolean fit) {
   super(0, 0, 0, 0);
   borderWidth = 0.5f;
   border = BOX;
   column.setLeading(0, 1);
   if (fit) {
     this.image = image;
     setPadding(borderWidth / 2);
   } else {
     image.setScaleToFitLineWhenOverflow(false);
     column.addText(this.phrase = new Phrase(new Chunk(image, 0, 0, true)));
     setPadding(0);
   }
 }
 /**
  * Adds an iText element to the cell.
  *
  * @param element
  */
 public void addElement(Element element) {
   if (table != null) {
     table = null;
     column.setText(null);
   }
   if (element instanceof PdfPTable) {
     ((PdfPTable) element).setSplitLate(false);
   } else if (element instanceof PdfDiv) {
     for (Element divChildElement : ((PdfDiv) element).getContent()) {
       if (divChildElement instanceof PdfPTable) {
         ((PdfPTable) divChildElement).setSplitLate(false);
       }
     }
   }
   column.addElement(element);
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * Gets the run direction of the text content in the cell
  *
  * @return One of the following values: PdfWriter.RUN_DIRECTION_DEFAULT,
  *     PdfWriter.RUN_DIRECTION_NO_BIDI, PdfWriter.RUN_DIRECTION_LTR or
  *     PdfWriter.RUN_DIRECTION_RTL.
  */
 public int getRunDirection() {
   return column.getRunDirection();
 }
 /**
  * Sets the ratio between the extra word spacing and the extra character spacing when the text is
  * fully justified. Extra word spacing will grow <CODE>spaceCharRatio</CODE> times more than extra
  * character spacing. If the ratio is <CODE>PdfWriter.NO_SPACE_CHAR_RATIO</CODE> then the extra
  * character spacing will be zero.
  *
  * @param spaceCharRatio the ratio between the extra word spacing and the extra character spacing
  */
 public void setSpaceCharRatio(float spaceCharRatio) {
   column.setSpaceCharRatio(spaceCharRatio);
 }
Beispiel #10
0
 /**
  * Sets the run direction of the text content in the cell. May be either of:
  * PdfWriter.RUN_DIRECTION_DEFAULT, PdfWriter.RUN_DIRECTION_NO_BIDI, PdfWriter.RUN_DIRECTION_LTR
  * or PdfWriter.RUN_DIRECTION_RTL.
  *
  * @param runDirection
  */
 public void setRunDirection(int runDirection) {
   column.setRunDirection(runDirection);
 }
Beispiel #11
0
 /**
  * Sets the horizontal alignment for the cell. It could be <CODE>Element.ALIGN_CENTER</CODE> for
  * example.
  *
  * @param horizontalAlignment The horizontal alignment
  */
 public void setHorizontalAlignment(int horizontalAlignment) {
   column.setAlignment(horizontalAlignment);
 }
Beispiel #12
0
 /**
  * Gets the space/character extra spacing ratio for fully justified text.
  *
  * @return the space/character extra spacing ratio
  */
 public float getSpaceCharRatio() {
   return column.getSpaceCharRatio();
 }
Beispiel #13
0
 /**
  * Sets the arabic shaping options. The option can be AR_NOVOWEL, AR_COMPOSEDTASHKEEL and AR_LIG.
  *
  * @param arabicOptions the arabic shaping options
  */
 public void setArabicOptions(int arabicOptions) {
   column.setArabicOptions(arabicOptions);
 }
Beispiel #14
0
 /**
  * Enables/ Disables adjustment of first line height based on max ascender.
  *
  * @param useAscender adjust height if true
  */
 public void setUseAscender(boolean useAscender) {
   column.setUseAscender(useAscender);
 }
Beispiel #15
0
 /** Constructs an empty <CODE>PdfPCell</CODE>. The default padding is 2. */
 public PdfPCell() {
   super(0, 0, 0, 0);
   borderWidth = 0.5f;
   border = BOX;
   column.setLeading(0, 1);
 }
Beispiel #16
0
 /**
  * Sets the following paragraph lines indent.
  *
  * @param indent the indent
  */
 public void setFollowingIndent(float indent) {
   column.setFollowingIndent(indent);
 }
Beispiel #17
0
 /**
  * Gets the extra space between paragraphs.
  *
  * @return the extra space between paragraphs
  */
 public float getExtraParagraphSpace() {
   return column.getExtraParagraphSpace();
 }
Beispiel #18
0
 /**
  * Sets the extra space between paragraphs.
  *
  * @param extraParagraphSpace the extra space between paragraphs
  */
 public void setExtraParagraphSpace(float extraParagraphSpace) {
   column.setExtraParagraphSpace(extraParagraphSpace);
 }
Beispiel #19
0
 /**
  * Gets the variable leading.
  *
  * @return the leading
  */
 public float getMultipliedLeading() {
   return column.getMultipliedLeading();
 }
Beispiel #20
0
 /**
  * Gets the fixed leading.
  *
  * @return the leading
  */
 public float getLeading() {
   return column.getLeading();
 }
Beispiel #21
0
 /**
  * Sets the leading fixed and variable. The resultant leading will be:
  * fixedLeading+multipliedLeading*maxFontSize where maxFontSize is the size of the biggest font in
  * the line.
  *
  * @param fixedLeading the fixed leading
  * @param multipliedLeading the variable leading
  */
 public void setLeading(float fixedLeading, float multipliedLeading) {
   column.setLeading(fixedLeading, multipliedLeading);
 }
Beispiel #22
0
 /**
  * Setter for property image.
  *
  * @param image New value of property image.
  */
 public void setImage(Image image) {
   column.setText(null);
   table = null;
   this.image = image;
 }
Beispiel #23
0
 /**
  * Sets the <CODE>Phrase</CODE> for this cell.
  *
  * @param phrase the <CODE>Phrase</CODE>
  */
 public void setPhrase(Phrase phrase) {
   table = null;
   image = null;
   column.setText(this.phrase = phrase);
 }
Beispiel #24
0
 /**
  * Gets the arabic shaping options.
  *
  * @return the arabic shaping options
  */
 public int getArabicOptions() {
   return column.getArabicOptions();
 }
Beispiel #25
0
 /**
  * Sets the right paragraph lines indent.
  *
  * @param indent the indent
  */
 public void setRightIndent(float indent) {
   column.setRightIndent(indent);
 }
Beispiel #26
0
 /**
  * Gets state of first line height based on max ascender
  *
  * @return true if an ascender is to be used.
  */
 public boolean isUseAscender() {
   return column.isUseAscender();
 }
Beispiel #27
0
 /**
  * Gets the right paragraph lines indent.
  *
  * @return the indent
  */
 public float getRightIndent() {
   return column.getRightIndent();
 }
Beispiel #28
0
 /**
  * Gets the following paragraph lines indent.
  *
  * @return the indent
  */
 public float getFollowingIndent() {
   return column.getFollowingIndent();
 }
Beispiel #29
0
 /**
  * Gets the horizontal alignment for the cell.
  *
  * @return the horizontal alignment for the cell
  */
 public int getHorizontalAlignment() {
   return column.getAlignment();
 }