Skip to content

Commit

Permalink
Fix the word column width which is larger like 22in (#1867) (#1869)
Browse files Browse the repository at this point in the history
  • Loading branch information
speckyspooky authored Aug 22, 2024
1 parent 545cb24 commit cad5146
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,10 @@ private int[] computeTblColumnWidths(ITableContent table, int tblWidth) {
tblColumns[i] = -1;
count++;
} else {
tblColumns[i] = WordUtil.convertTo(col.getWidth(), tblWidth, reportDpi);
int colWidth = WordUtil.convertTo(col.getWidth(), tblWidth, reportDpi);
// validate the maximum of column width
colWidth = (colWidth > WordUtil.MAX_ELEMENT_WIDTH_INCH_TWIPS) ? WordUtil.MAX_ELEMENT_WIDTH_INCH_TWIPS : colWidth;
tblColumns[i] = colWidth;
total += tblColumns[i];
}
}
Expand All @@ -1490,7 +1493,14 @@ private int[] computeTblColumnWidths(ITableContent table, int tblWidth) {
return tblColumns;
}
tblWidth = Math.min(tblWidth, context.getCurrentWidth());
return EmitterUtil.resizeTableColumn(tblWidth, tblColumns, count, total);
tblWidth = (tblWidth > WordUtil.MAX_ELEMENT_WIDTH_INCH_TWIPS) ? WordUtil.MAX_ELEMENT_WIDTH_INCH_TWIPS : tblWidth;

int[] tblColWidth = EmitterUtil.resizeTableColumn(tblWidth, tblColumns, count, total);
// validate the maximum of column width
for (int i = 0; i < tblColWidth.length; i++) {
tblColWidth[i] = (tblColWidth[i] > WordUtil.MAX_ELEMENT_WIDTH_INCH_TWIPS) ? WordUtil.MAX_ELEMENT_WIDTH_INCH_TWIPS : tblColWidth[i];
}
return tblColWidth;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public class WordUtil {

public static final double INCH_TWIPS = INCH_PT * PT_TWIPS;

/**
* maximum value of word column width 22in to TWIPS
*/
public static final int MAX_ELEMENT_WIDTH_INCH_TWIPS = 31680;

// Bookmark names must begin with a letter and can contain numbers.
// spaces can not be included in a bookmark name,
// but the underscore character can be used to separate words
Expand Down

0 comments on commit cad5146

Please sign in to comment.