From 15d39413f36cdd59443965d4510aac8a9e0d1fcf Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Wed, 31 May 2023 21:33:45 +0100 Subject: [PATCH] scaled changes --- .../software/SPDF/config/EndpointConfiguration.java | 2 +- .../api/{other => }/MultiPageLayoutController.java | 2 +- .../controller/api/{other => }/ScalePagesController.java | 7 +++---- src/main/resources/static/images/scale-pages.svg | 4 ++-- src/main/resources/templates/other/scale-pages.html | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) rename src/main/java/stirling/software/SPDF/controller/api/{other => }/MultiPageLayoutController.java (98%) rename src/main/java/stirling/software/SPDF/controller/api/{other => }/ScalePagesController.java (93%) diff --git a/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java b/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java index 686a6b38..6bdb0074 100644 --- a/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java +++ b/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java @@ -165,7 +165,7 @@ public class EndpointConfiguration { addEndpointToGroup("Java", "change-metadata"); addEndpointToGroup("Java", "cert-sign"); addEndpointToGroup("Java", "multi-page-layout"); - + addEndpointToGroup("Java", "scale-pages"); //Javascript diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/MultiPageLayoutController.java b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java similarity index 98% rename from src/main/java/stirling/software/SPDF/controller/api/other/MultiPageLayoutController.java rename to src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java index ef1b699e..7dc9c51f 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/MultiPageLayoutController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/ScalePagesController.java b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java similarity index 93% rename from src/main/java/stirling/software/SPDF/controller/api/other/ScalePagesController.java rename to src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java index 8db0fa80..a5f874b2 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/ScalePagesController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -25,6 +25,7 @@ import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; +import stirling.software.SPDF.utils.WebResponseUtils; @RestController public class ScalePagesController { @@ -81,8 +82,6 @@ public class ScalePagesController { outputPdf.close(); byte[] pdfContent = baos.toByteArray(); pdfDoc.close(); - return ResponseEntity.ok() - .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_modified.pdf\"") - .body(pdfContent); + return WebResponseUtils.bytesToWebResponse(pdfContent, file.getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_scaled.pdf"); } } diff --git a/src/main/resources/static/images/scale-pages.svg b/src/main/resources/static/images/scale-pages.svg index bc505957..dc0acc3c 100644 --- a/src/main/resources/static/images/scale-pages.svg +++ b/src/main/resources/static/images/scale-pages.svg @@ -1,3 +1,3 @@ - - + + \ No newline at end of file diff --git a/src/main/resources/templates/other/scale-pages.html b/src/main/resources/templates/other/scale-pages.html index d6abd561..b2acd961 100644 --- a/src/main/resources/templates/other/scale-pages.html +++ b/src/main/resources/templates/other/scale-pages.html @@ -2,7 +2,7 @@ - +