Fixed issue for protocol number in pdf

This commit is contained in:
nisha
2024-10-14 12:08:56 +05:30
parent 7fd5a4cb27
commit 89d512c4c5

View File

@@ -94,15 +94,14 @@ public class PdfDao {
// Application ID section (Centered)
// pageEvent.setTotalPages(writer.getPageNumber());
Paragraph appId = new Paragraph("ID domanda :" +"XX00");
String protocolNumber="XX00";
if(applicationEntity.getProtocol()!=null) {
protocolNumber= String.valueOf(applicationEntity.getProtocol().getProtocolNumber());
}
Paragraph appId = new Paragraph("ID domanda :" +protocolNumber);
appId.setAlignment(Element.ALIGN_RIGHT);
document.add(appId);
if(applicationEntity.getProtocol()!=null) {
appId = new Paragraph("ID domanda :"+String.valueOf(applicationEntity.getProtocol().getProtocolNumber()), valueFont);
appId.setAlignment(Element.ALIGN_RIGHT);
document.add(appId);
}
document.add(new Paragraph(" "));
addColoredLines(writer,document,greenColor);
@@ -346,14 +345,17 @@ public class PdfDao {
return totalPages;
}
private Document createPdfTable(List<Map<String, String>> extractedData,Document document) throws DocumentException { // Create a PdfPTable with 2 columns
private Document createPdfTable(List<Map<String, String>> extractedData,Document document) throws DocumentException {
// Create a PdfPTable with 2 columns
PdfPTable table = new PdfPTable(2); // Initial assumption for 2 columns
table.setWidthPercentage(100); // Set table width to 100%
table.setTableEvent(new RoundedBorderEvent());
Font textFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new BaseColor(105, 105, 105)); // Gray text
boolean combinedHeaderAdded = false; // Flag to track if headers for combined have been added
float rowHeight = 50f; // Example row height, adjust as necessary
float maxTableHeight = 700f; // Maximum height of the table before a page break
int rowCount = 0; // Counter for rows
float[] columnWidths = {0.7f, 0.3f};
table.setWidths(columnWidths);
// Add table header
@@ -484,7 +486,26 @@ public class PdfDao {
// Return the populated table
return document;
}
public static class RoundedBorderEvent implements PdfPTableEvent {
@Override
public void tableLayout(PdfPTable table, float[][] widths, float[] heights,
int headerRows, int rowStart, PdfContentByte[] canvases) {
PdfContentByte canvas = canvases[PdfPTable.BASECANVAS];
// Get the table boundaries
float left = widths[0][0];
float right = widths[0][widths[0].length - 1];
float top = heights[0];
float bottom = heights[heights.length - 1];
// Define the corner radius
float radius = 20f;
// Draw a rounded rectangle around the table
canvas.roundRectangle(left, bottom, right - left, top - bottom, radius);
canvas.stroke();
}
}
public List<FieldLabelValuePairRequest> getFormFieldsToLabels(FormApplicationResponse responseBean) {
List<FieldLabelValuePairRequest> labelValuePairs = new ArrayList<>();