updated checkbox code
This commit is contained in:
@@ -10,14 +10,12 @@ import com.itextpdf.text.Rectangle;
|
||||
import com.itextpdf.text.pdf.*;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.model.request.FieldLabelValuePairRequest;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.service.CallService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -62,7 +60,8 @@ public class PdfDao {
|
||||
// writer.setPageEvent(pageEvent);
|
||||
document.open();
|
||||
// pageEvent.setTotalPages(writer.getPageNumber());
|
||||
addLogo(document, "logo.jpg"); // Add your image path here
|
||||
// addLogo(document, "logo.jpg"); // Add your image path here the migration code after cherry-pick
|
||||
addLogo(document, "https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/logo.jpg");
|
||||
|
||||
|
||||
BaseColor customColor = new BaseColor(0, 128, 0); // Adjust RGB values as needed
|
||||
@@ -234,44 +233,42 @@ public class PdfDao {
|
||||
|
||||
String fieldValue=Utils.convertToString(value);
|
||||
Image img = null; // This may throw MalformedURLException
|
||||
if (fieldValue.equalsIgnoreCase("true")) {
|
||||
if (fieldValue.trim().equalsIgnoreCase("true")) {
|
||||
// Use images for tick and cross
|
||||
try {
|
||||
img = Image.getInstance("true.jpg");
|
||||
// img = Image.getInstance("true.jpg"); update code after cherry-pick
|
||||
img = Image.getInstance("https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/true.png");
|
||||
} catch (IOException e) {
|
||||
log.error("Error while uploading image for pdf for true");
|
||||
}
|
||||
img.scaleAbsolute(15, 15); // Resize the image if needed
|
||||
|
||||
PdfPCell cell = new PdfPCell(img);
|
||||
cell.setPadding(5f); // Increase padding for better spacing
|
||||
cell.setPaddingLeft(leftMargin); // Increase left margin for value
|
||||
cell.setBorder(Rectangle.NO_BORDER); // Remove border for value cell
|
||||
cell.setMinimumHeight(30f);
|
||||
cell.setVerticalAlignment(Element.ALIGN_LEFT);
|
||||
cell.setCellEvent(new RoundedCorners()); // Apply rounded corners
|
||||
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
||||
valueTable.addCell(cell);
|
||||
cell.setPadding(0); // Remove padding
|
||||
cell.setBorder(Rectangle.NO_BORDER); // Remove border
|
||||
cell.setMinimumHeight(15f); // Set height to fit checkbox image
|
||||
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||
cell.setHorizontalAlignment(Element.ALIGN_LEFT); // Align the checkbox image to the left
|
||||
|
||||
valueTable.addCell(cell); // Add cell with checkbox to the table
|
||||
document.add(valueTable);
|
||||
}
|
||||
else if (fieldValue.equalsIgnoreCase("false")) {
|
||||
} else if (fieldValue.trim().equalsIgnoreCase("false")) {
|
||||
// Use images for tick and cross
|
||||
try {
|
||||
img = Image.getInstance("false.jpg");
|
||||
img = Image.getInstance("https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/false.png");
|
||||
} catch (IOException e) {
|
||||
log.error("Error while uploading image for pdf for true");
|
||||
log.error("Error while uploading image for pdf for false");
|
||||
}
|
||||
img.scaleAbsolute(15, 15); // Resize the image if needed
|
||||
|
||||
PdfPCell cell = new PdfPCell(img);
|
||||
cell.setPadding(5f); // Increase padding for better spacing
|
||||
cell.setPaddingLeft(leftMargin); // Increase left margin for value
|
||||
cell.setBorder(Rectangle.NO_BORDER); // Remove border for value cell
|
||||
cell.setMinimumHeight(30f);
|
||||
cell.setVerticalAlignment(Element.ALIGN_LEFT);
|
||||
cell.setCellEvent(new RoundedCorners()); // Apply rounded corners
|
||||
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
||||
valueTable.addCell(cell);
|
||||
cell.setPadding(0); // Remove padding
|
||||
cell.setBorder(Rectangle.NO_BORDER); // Remove border
|
||||
cell.setMinimumHeight(15f); // Set height to fit checkbox image
|
||||
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||
cell.setHorizontalAlignment(Element.ALIGN_LEFT); // Align the checkbox image to the left
|
||||
|
||||
valueTable.addCell(cell); // Add cell with checkbox to the table
|
||||
document.add(valueTable);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user