Merge pull request #343 from Kitzanos/pdf-banner-fix-prod

Cherry-pick (PDF logo fix)
This commit is contained in:
Rinaldo
2025-09-16 10:08:51 +02:00
committed by GitHub

View File

@@ -77,7 +77,7 @@ public class PdfDao {
// CustomPageEvent pageEvent = new CustomPageEvent(call.getName(), 0);
// writer.setPageEvent(pageEvent);
document.open();
String logoUrl=null;
String logoUrl=defaultLogoUrl;
Optional<HubEntity> hubEntity=hubRepository.findById(applicationEntity.getHubId());
if (Boolean.TRUE.equals(validator.isProductionProfileActivated()) && applicationEntity.getCall().getId().equals(23l)) {
@@ -85,16 +85,16 @@ public class PdfDao {
}
else if(hubEntity.isPresent()) {
if (hubEntity.get().getUniqueUuid().equals("p4lk3bcx1RStqTaIVVbXs")) {
defaultLogoUrl = hubEntity.get().getPdfBanner();
logoUrl = hubEntity.get().getPdfBanner();
}
if (hubEntity.get().getUniqueUuid().equals("t7jh5wfg9QXylNaTZkPoE")) {
defaultLogoUrl = hubEntity.get().getPdfBanner();
logoUrl = hubEntity.get().getPdfBanner();
}
logoUrl=defaultLogoUrl;
}
// pageEvent.setTotalPages(writer.getPageNumber());
// addLogo(document, "logo.jpg"); // Add your image path here the migration code after cherry-pick
addLogo(document, logoUrl);
addLogo(document, logoUrl,applicationEntity);
BaseColor customColor = new BaseColor(0, 128, 0); // Adjust RGB values as needed
@@ -672,10 +672,15 @@ public class PdfDao {
return valueToFind;
}
public void addLogo(Document document, String logoPath) throws Exception {
public void addLogo(Document document, String logoPath,ApplicationEntity applicationEntity) throws Exception {
Image logo = Image.getInstance(logoPath);
logo.scaleToFit(document.getPageSize().getWidth() - document.leftMargin() - document.rightMargin(), // Fit to document width
document.getPageSize().getHeight() / 4); // Adjust the height as needed (1/4th of the page height)
if (Boolean.TRUE.equals(validator.isProductionProfileActivated()) && applicationEntity.getCall().getId().equals(23l)) {
logo.scaleToFit(120, 60);
}
else {
logo.scaleToFit(document.getPageSize().getWidth() - document.leftMargin() - document.rightMargin(), // Fit to document width
document.getPageSize().getHeight() / 4); // Adjust the height as needed (1/4th of the page height)
}
logo.setAlignment(Image.ALIGN_CENTER); // Align logo to center
document.add(logo);