Skip to content

Commit

Permalink
#837 Modified PdfPTable add cell method to return cell (#844)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybob007 authored Feb 13, 2024
1 parent 57331f8 commit de7a7f8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions openpdf/src/main/java/com/lowagie/text/pdf/PdfPTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public PdfPCell getDefaultCell() {
*
* @param cell the cell element
*/
public void addCell(PdfPCell cell) {
public PdfPCell addCell(PdfPCell cell) {
rowCompleted = false;
PdfPCell ncell = new PdfPCell(cell);

Expand Down Expand Up @@ -509,6 +509,8 @@ public void addCell(PdfPCell cell) {
currentRow[currentRowIdx] = ncell;
currentRowIdx += colspan;
}

return ncell;
}

/**
Expand Down Expand Up @@ -589,19 +591,20 @@ boolean rowSpanAbove(int currRow, int currCol) {
*
* @param text the text for the cell
*/
public void addCell(String text) {
addCell(new Phrase(text));
public PdfPCell addCell(String text) {
return addCell(new Phrase(text));
}

/**
* Adds a nested table.
*
* @param table the table to be added to the cell
*/
public void addCell(PdfPTable table) {
public PdfPCell addCell(PdfPTable table) {
defaultCell.setTable(table);
addCell(defaultCell);
defaultCell.setTable(null);
return defaultCell;
}

/**
Expand All @@ -610,21 +613,23 @@ public void addCell(PdfPTable table) {
* @param image the <CODE>Image</CODE> to add to the table.
* This image will fit in the cell
*/
public void addCell(Image image) {
public PdfPCell addCell(Image image) {
defaultCell.setImage(image);
addCell(defaultCell);
defaultCell.setImage(null);
return defaultCell;
}

/**
* Adds a cell element.
*
* @param phrase the <CODE>Phrase</CODE> to be added to the cell
*/
public void addCell(Phrase phrase) {
public PdfPCell addCell(Phrase phrase) {
defaultCell.setPhrase(phrase);
addCell(defaultCell);
defaultCell.setPhrase(null);
return defaultCell;
}

/**
Expand Down

0 comments on commit de7a7f8

Please sign in to comment.