Fixed PDF spacing issue
This commit is contained in:
@@ -40,7 +40,7 @@ import java.util.stream.Collectors;
|
|||||||
@Component
|
@Component
|
||||||
public class PdfDao {
|
public class PdfDao {
|
||||||
|
|
||||||
@Value("${default.hub.pdf.banner}")
|
@Value("${default.pdf.banner}")
|
||||||
private String defaultLogoUrl;
|
private String defaultLogoUrl;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -77,16 +77,20 @@ public class PdfDao {
|
|||||||
// CustomPageEvent pageEvent = new CustomPageEvent(call.getName(), 0);
|
// CustomPageEvent pageEvent = new CustomPageEvent(call.getName(), 0);
|
||||||
// writer.setPageEvent(pageEvent);
|
// writer.setPageEvent(pageEvent);
|
||||||
document.open();
|
document.open();
|
||||||
String logoUrl=defaultLogoUrl;
|
String logoUrl=null;
|
||||||
|
|
||||||
Optional<HubEntity> hubEntity=hubRepository.findById(applicationEntity.getHubId());
|
Optional<HubEntity> hubEntity=hubRepository.findById(applicationEntity.getHubId());
|
||||||
if(hubEntity.isPresent()) {
|
if (Boolean.TRUE.equals(validator.isProductionProfileActivated()) && applicationEntity.getCall().getId().equals(23l)) {
|
||||||
|
logoUrl=defaultLogoUrl;
|
||||||
|
}
|
||||||
|
else if(hubEntity.isPresent()) {
|
||||||
if (hubEntity.get().getUniqueUuid().equals("p4lk3bcx1RStqTaIVVbXs")) {
|
if (hubEntity.get().getUniqueUuid().equals("p4lk3bcx1RStqTaIVVbXs")) {
|
||||||
defaultLogoUrl = hubEntity.get().getPdfBanner();
|
defaultLogoUrl = hubEntity.get().getPdfBanner();
|
||||||
}
|
}
|
||||||
if (hubEntity.get().getUniqueUuid().equals("t7jh5wfg9QXylNaTZkPoE")) {
|
if (hubEntity.get().getUniqueUuid().equals("t7jh5wfg9QXylNaTZkPoE")) {
|
||||||
defaultLogoUrl = hubEntity.get().getPdfBanner();
|
defaultLogoUrl = hubEntity.get().getPdfBanner();
|
||||||
}
|
}
|
||||||
|
logoUrl=defaultLogoUrl;
|
||||||
}
|
}
|
||||||
// pageEvent.setTotalPages(writer.getPageNumber());
|
// pageEvent.setTotalPages(writer.getPageNumber());
|
||||||
// addLogo(document, "logo.jpg"); // Add your image path here the migration code after cherry-pick
|
// addLogo(document, "logo.jpg"); // Add your image path here the migration code after cherry-pick
|
||||||
@@ -112,7 +116,7 @@ public class PdfDao {
|
|||||||
|
|
||||||
ApplicationGetResponseBean applicationGetResponseBean=applicationDao.getApplicationByFormId(request, applicationId, null);
|
ApplicationGetResponseBean applicationGetResponseBean=applicationDao.getApplicationByFormId(request, applicationId, null);
|
||||||
for(FormApplicationResponse formApplicationResponse: applicationGetResponseBean.getForm()) {
|
for(FormApplicationResponse formApplicationResponse: applicationGetResponseBean.getForm()) {
|
||||||
List<FieldLabelValuePairRequest> fieldLabelValuePairRequests = getFormFieldsToLabels(formApplicationResponse,writer,document);
|
List<FieldLabelValuePairRequest> fieldLabelValuePairRequests = getFormFieldsToLabels(formApplicationResponse,writer,document,applicationEntity);
|
||||||
addColoredLines(writer,document,greenColor);
|
addColoredLines(writer,document,greenColor);
|
||||||
document.add(new Paragraph(" ")); // Add line break
|
document.add(new Paragraph(" ")); // Add line break
|
||||||
}
|
}
|
||||||
@@ -132,10 +136,16 @@ public class PdfDao {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addLabelValuePair(PdfWriter writer,Document document, String label, Object value, Font labelFont,Font valueFont,ContentResponseBean contentResponseBean) throws DocumentException {
|
private void addLabelValuePair(PdfWriter writer,Document document, String label, Object value, Font labelFont,Font valueFont,ContentResponseBean contentResponseBean, ApplicationEntity applicationEntity) throws DocumentException {
|
||||||
// Add label
|
// Add label
|
||||||
Map<String, Boolean> stateFieldMap= new HashMap<>();
|
Map<String, Boolean> stateFieldMap= new HashMap<>();
|
||||||
|
if (Boolean.TRUE.equals(validator.isProductionProfileActivated()) && applicationEntity.getCall().getId().equals(23l)) {
|
||||||
|
for (SettingResponseBean settingResponseBean : contentResponseBean.getSettings()) {
|
||||||
|
if (settingResponseBean.getName().equals("isRequestedAmount") && settingResponseBean.getValue().equals(Boolean.TRUE)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Paragraph labelParagraph = new Paragraph(label, labelFont);
|
Paragraph labelParagraph = new Paragraph(label, labelFont);
|
||||||
labelParagraph.setSpacingAfter(-10f);
|
labelParagraph.setSpacingAfter(-10f);
|
||||||
document.add(labelParagraph);
|
document.add(labelParagraph);
|
||||||
@@ -151,10 +161,10 @@ public class PdfDao {
|
|||||||
|
|
||||||
// Define start and end points for the line (relative to the page size and margins)
|
// Define start and end points for the line (relative to the page size and margins)
|
||||||
|
|
||||||
if (yPos <= 140) {
|
// if (yPos <= 140) {
|
||||||
// If xEnd is less than or equal to 200, generate a new page
|
// // If xEnd is less than or equal to 200, generate a new page
|
||||||
document.newPage();
|
// document.newPage();
|
||||||
} // Add a gap between the label and value
|
// } // Add a gap between the label and value
|
||||||
document.add(new Paragraph(" ")); // Adding an empty paragraph for spacing
|
document.add(new Paragraph(" ")); // Adding an empty paragraph for spacing
|
||||||
// Create value cell with rounded corners
|
// Create value cell with rounded corners
|
||||||
PdfPTable valueTable = new PdfPTable(1);
|
PdfPTable valueTable = new PdfPTable(1);
|
||||||
@@ -268,6 +278,7 @@ public class PdfDao {
|
|||||||
document.add(valueTable);
|
document.add(valueTable);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
String fieldValue1 = (String) value;
|
String fieldValue1 = (String) value;
|
||||||
if (Utils.isValidDateString(fieldValue1)) {
|
if (Utils.isValidDateString(fieldValue1)) {
|
||||||
@@ -503,7 +514,7 @@ public class PdfDao {
|
|||||||
canvas.stroke();
|
canvas.stroke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public List<FieldLabelValuePairRequest> getFormFieldsToLabels(FormApplicationResponse responseBean,PdfWriter writer,Document document) {
|
public List<FieldLabelValuePairRequest> getFormFieldsToLabels(FormApplicationResponse responseBean,PdfWriter writer,Document document,ApplicationEntity applicationEntity) {
|
||||||
List<FieldLabelValuePairRequest> labelValuePairs = new ArrayList<>();
|
List<FieldLabelValuePairRequest> labelValuePairs = new ArrayList<>();
|
||||||
|
|
||||||
Font labelFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12,new BaseColor(113,121,126)); // Light grey);
|
Font labelFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12,new BaseColor(113,121,126)); // Light grey);
|
||||||
@@ -547,13 +558,20 @@ public class PdfDao {
|
|||||||
labelCell.setBorder(Rectangle.NO_BORDER);
|
labelCell.setBorder(Rectangle.NO_BORDER);
|
||||||
labelCell.setGrayFill(7);
|
labelCell.setGrayFill(7);
|
||||||
labelCell.setPadding(5);
|
labelCell.setPadding(5);
|
||||||
labelParagraph.setSpacingAfter(-10f);
|
labelCell.setNoWrap(false); // wrap long text
|
||||||
|
labelCell.setUseAscender(true);
|
||||||
|
labelCell.setUseDescender(true); // allow text wrapping
|
||||||
|
|
||||||
|
|
||||||
// Create a PdfPTable with 1 column and add the PdfPCell to it
|
// Create a PdfPTable with 1 column and add the PdfPCell to it
|
||||||
PdfPTable table = new PdfPTable(1);
|
PdfPTable table = new PdfPTable(1);
|
||||||
table.setWidthPercentage(100);
|
table.setWidthPercentage(100);
|
||||||
table.addCell(labelCell);
|
table.addCell(labelCell);
|
||||||
|
table.setSplitLate(false);
|
||||||
|
table.setSplitRows(true);
|
||||||
|
table.setKeepTogether(false);
|
||||||
|
labelCell.setMinimumHeight(0);
|
||||||
|
|
||||||
labelParagraph.add(table);
|
labelParagraph.add(table);
|
||||||
try {
|
try {
|
||||||
document.add(labelParagraph);
|
document.add(labelParagraph);
|
||||||
@@ -618,7 +636,7 @@ public class PdfDao {
|
|||||||
if((contentLabel==null || StringUtils.isEmpty(contentLabel)) && (fieldValue==null || StringUtils.isEmpty(fieldValue.toString()))) {
|
if((contentLabel==null || StringUtils.isEmpty(contentLabel)) && (fieldValue==null || StringUtils.isEmpty(fieldValue.toString()))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
addLabelValuePair(writer, document, contentLabel, fieldValue, labelFont, valueFont, content);
|
addLabelValuePair(writer, document, contentLabel, fieldValue, labelFont, valueFont, content,applicationEntity);
|
||||||
} catch (DocumentException e) {
|
} catch (DocumentException e) {
|
||||||
log.error("Error checking object: " + e.getMessage(), e);
|
log.error("Error checking object: " + e.getMessage(), e);
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ api.pecUrl=https://ws.pecmassiva.com
|
|||||||
application.amendment.expiration.days=30
|
application.amendment.expiration.days=30
|
||||||
default.email.signature=Gepafin S.p.a
|
default.email.signature=Gepafin S.p.a
|
||||||
|
|
||||||
default.hub.pdf.banner=https://mementoresources.s3.amazonaws.com/gepafin/staging/template/gepafin-logo.jpg
|
default.pdf.banner=https://mementoresources.s3.amazonaws.com/gepafin/production/template/gepafin-logo-only.jpg
|
||||||
|
|
||||||
#feign client config
|
#feign client config
|
||||||
spring.cloud.openfeign.client.config.default.connectTimeout=300000
|
spring.cloud.openfeign.client.config.default.connectTimeout=300000
|
||||||
|
|||||||
Reference in New Issue
Block a user