Updated code for pdf table issue
This commit is contained in:
@@ -277,6 +277,9 @@ public class PdfDao {
|
||||
if(Utils.isValidDateString(fieldValue1)){
|
||||
fieldValue1=Utils.formatDateString(String.valueOf(value));
|
||||
}
|
||||
if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){
|
||||
fieldValue= String.valueOf(Utils.convertItalianAmountToDouble(fieldValue));
|
||||
}
|
||||
PdfPCell valueCell = new PdfPCell(new Phrase(fieldValue1, valueFont));
|
||||
valueCell.setPadding(5f); // Increase padding for better spacing
|
||||
valueCell.setPaddingLeft(leftMargin); // Increase left margin for value
|
||||
@@ -352,7 +355,6 @@ public class PdfDao {
|
||||
List<String> orderedKeys = new ArrayList<>(trueKeys);
|
||||
orderedKeys.addAll(falseKeys);
|
||||
// Iterate through extracted data to populate the table
|
||||
for (Map<String, Object> row : extractedData) {
|
||||
// Add headers once
|
||||
if (!headersAdded) {
|
||||
for (String key : orderedKeys) {
|
||||
@@ -369,16 +371,23 @@ public class PdfDao {
|
||||
}
|
||||
|
||||
// Add data rows matching stateFieldMap keys
|
||||
for (String key : orderedKeys) {
|
||||
Object value = row.getOrDefault(key, ""); // Fetch value or use empty string if key not present
|
||||
PdfPCell dataCell = new PdfPCell(new Phrase(value != null ? value.toString() : "", textFont));
|
||||
dataCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell
|
||||
dataCell.setMinimumHeight(rowHeight);
|
||||
dataCell.setFixedHeight(rowHeight);
|
||||
dataCell.setPadding(7f);
|
||||
for (Map<String, Object> row : extractedData) {
|
||||
// Add data rows matching stateFieldMap keys
|
||||
for (String key : orderedKeys) {
|
||||
if (stateFieldMap.containsKey(key)) { // Only add data cell if key is in stateFieldMap
|
||||
Object value = row.getOrDefault(key, ""); // Fetch value or use empty string if key not present
|
||||
String fieldValue= (String) value;
|
||||
if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){
|
||||
fieldValue= String.valueOf(Utils.convertItalianAmountToDouble(fieldValue));
|
||||
}
|
||||
PdfPCell dataCell = new PdfPCell(new Phrase(fieldValue != null ?fieldValue: "", textFont));
|
||||
dataCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell
|
||||
dataCell.setMinimumHeight(rowHeight);
|
||||
dataCell.setPadding(7f);
|
||||
|
||||
table.addCell(dataCell); // Add the cell to the table
|
||||
}
|
||||
table.addCell(dataCell); // Add the cell to the table
|
||||
}
|
||||
}
|
||||
|
||||
// Check if adding another row would exceed max height
|
||||
if (table.getTotalHeight() + rowHeight > maxTableHeight) {
|
||||
|
||||
Reference in New Issue
Block a user