diff --git a/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java b/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java index 749ae2ac..7f429756 100644 --- a/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java +++ b/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java @@ -64,7 +64,8 @@ public class EndpointConfiguration { addEndpointToGroup("PageOps", "split-pdfs"); addEndpointToGroup("PageOps", "pdf-organizer"); addEndpointToGroup("PageOps", "rotate-pdf"); - + addEndpointToGroup("PageOps", "multi-page-layout"); + // Adding endpoints to "Convert" group addEndpointToGroup("Convert", "pdf-to-img"); addEndpointToGroup("Convert", "img-to-pdf"); @@ -82,6 +83,9 @@ public class EndpointConfiguration { addEndpointToGroup("Security", "remove-password"); addEndpointToGroup("Security", "change-permissions"); addEndpointToGroup("Security", "add-watermark"); + addEndpointToGroup("Security", "cert-sign"); + + // Adding endpoints to "Other" group addEndpointToGroup("Other", "ocr-pdf"); @@ -158,6 +162,9 @@ public class EndpointConfiguration { addEndpointToGroup("Java", "add-image"); addEndpointToGroup("Java", "extract-images"); addEndpointToGroup("Java", "change-metadata"); + addEndpointToGroup("Java", "cert-sign"); + addEndpointToGroup("Java", "multi-page-layout"); + //Javascript diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/CertSignController.java b/src/main/java/stirling/software/SPDF/controller/api/security/CertSignController.java index 925c57f8..a892d044 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/CertSignController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/CertSignController.java @@ -177,8 +177,17 @@ public class CertSignController { String signingDate = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss z").format(new Date()); // Prepare the text for the digital signature - String layer2Text = String.format("Digitally signed by: %s\nDate: %s\nReason: %s\nLocation: %s", name, signingDate, reason, location); + StringBuilder layer2TextBuilder = new StringBuilder(String.format("Digitally signed by: %s\nDate: %s", + name != null ? name : "Unknown", signingDate)); + if (reason != null && !reason.isEmpty()) { + layer2TextBuilder.append("\nReason: ").append(reason); + } + + if (location != null && !location.isEmpty()) { + layer2TextBuilder.append("\nLocation: ").append(location); + } + String layer2Text = layer2TextBuilder.toString(); // Get the PDF font and measure the width and height of the text block PdfFont font = PdfFontFactory.createFont(StandardFonts.HELVETICA_BOLD); float textWidth = Arrays.stream(layer2Text.split("\n")) @@ -206,12 +215,12 @@ public class CertSignController { // Configure the appearance of the digital signature appearance.setPageRect(rect) - .setContact(name) - .setPageNumber(pageNumber) - .setReason(reason) - .setLocation(location) - .setReuseAppearance(false) - .setLayer2Text(layer2Text); + .setContact(name != null ? name : "") + .setPageNumber(pageNumber) + .setReason(reason != null ? reason : "") + .setLocation(location != null ? location : "") + .setReuseAppearance(false) + .setLayer2Text(layer2Text.toString()); signer.setFieldName("sig"); } else { diff --git a/src/main/resources/templates/convert/pdf-to-img.html b/src/main/resources/templates/convert/pdf-to-img.html index 7e39f154..6e1597f5 100644 --- a/src/main/resources/templates/convert/pdf-to-img.html +++ b/src/main/resources/templates/convert/pdf-to-img.html @@ -43,7 +43,7 @@