diff --git a/README.md b/README.md index 70c87568..3e22e201 100644 --- a/README.md +++ b/README.md @@ -201,7 +201,7 @@ Stirling PDF allows easy customization of the app. Includes things like - Custom application name -- Custom slogans, icons, images, and even custom HTML (via file overrides) +- Custom slogans, icons, images css etc (via file overrides) (Does not currently support html) There are two options for this, either using the generated settings file ``settings.yml`` This file is located in the ``/configs`` directory and follows standard YAML formatting diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/FakeScanControllerWIP.java b/src/main/java/stirling/software/SPDF/controller/api/misc/FakeScanControllerWIP.java index 834c8711..2400c0d3 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/FakeScanControllerWIP.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/FakeScanControllerWIP.java @@ -37,6 +37,7 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import io.github.pixee.security.Filenames; +import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -51,7 +52,9 @@ public class FakeScanControllerWIP { private static final Logger logger = LoggerFactory.getLogger(FakeScanControllerWIP.class); + // TODO finish @PostMapping(consumes = "multipart/form-data", value = "/fake-scan") + @Hidden @Operation( summary = "Repair a PDF file", description = @@ -94,14 +97,13 @@ public class FakeScanControllerWIP { public BufferedImage processImage(BufferedImage image) { // Rotation - addDustAndHairs(image, 50); - // image = rotate(image, 1); + image = softenEdges(image, 50); + image = rotate(image, 1); - // image = softenEdges(image, 5); image = applyGaussianBlur(image, 0.5); - addGaussianNoise(image, 0.8); + addGaussianNoise(image, 0.5); image = linearStretch(image); - + addDustAndHairs(image, 3); return image; } @@ -156,32 +158,51 @@ public class FakeScanControllerWIP { g2.drawImage(image, 0, 0, null); g2.setComposite(AlphaComposite.DstIn); - g2.setPaint( - new GradientPaint( - 0, 0, new Color(0, 0, 0, 1f), 0, featherRadius, new Color(0, 0, 0, 0f))); - g2.fillRect(0, 0, width, featherRadius); // top edge + + // Top edge g2.setPaint( new GradientPaint( 0, - height - featherRadius, + 0, + new Color(0, 0, 0, 1f), + 0, + featherRadius * 2, + new Color(0, 0, 0, 0f))); + g2.fillRect(0, 0, width, featherRadius); + + // Bottom edge + g2.setPaint( + new GradientPaint( + 0, + height - featherRadius * 2, new Color(0, 0, 0, 0f), 0, height, new Color(0, 0, 0, 1f))); - g2.fillRect(0, height - featherRadius, width, featherRadius); // bottom edge + g2.fillRect(0, height - featherRadius, width, featherRadius); + + // Left edge g2.setPaint( new GradientPaint( - 0, 0, new Color(0, 0, 0, 1f), featherRadius, 0, new Color(0, 0, 0, 0f))); - g2.fillRect(0, 0, featherRadius, height); // left edge + 0, + 0, + new Color(0, 0, 0, 1f), + featherRadius * 2, + 0, + new Color(0, 0, 0, 0f))); + g2.fillRect(0, 0, featherRadius, height); + + // Right edge g2.setPaint( new GradientPaint( - width - featherRadius, + width - featherRadius * 2, 0, new Color(0, 0, 0, 0f), width, 0, new Color(0, 0, 0, 1f))); - g2.fillRect(width - featherRadius, 0, featherRadius, height); // right edge + g2.fillRect(width - featherRadius, 0, featherRadius, height); + g2.dispose(); return output; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/PrintFileController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/PrintFileController.java index 66da699e..bc0a6715 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/PrintFileController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/PrintFileController.java @@ -20,12 +20,10 @@ import org.apache.pdfbox.printing.PDFPageable; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.PrintFileRequest; @@ -35,12 +33,13 @@ import stirling.software.SPDF.model.api.misc.PrintFileRequest; @Tag(name = "Misc", description = "Miscellaneous APIs") public class PrintFileController { - //TODO - //@PostMapping(value = "/print-file", consumes = "multipart/form-data") - //@Operation( + // TODO + // @PostMapping(value = "/print-file", consumes = "multipart/form-data") + // @Operation( // summary = "Prints PDF/Image file to a set printer", // description = - // "Input of PDF or Image along with a printer name/URL/IP to match against to send it to (Fire and forget) Input:Any Output:N/A Type:SISO") + // "Input of PDF or Image along with a printer name/URL/IP to match against to + // send it to (Fire and forget) Input:Any Output:N/A Type:SISO") public ResponseEntity printFile(@ModelAttribute PrintFileRequest request) throws IOException { MultipartFile file = request.getFileInput(); diff --git a/src/main/java/stirling/software/SPDF/utils/PdfUtils.java b/src/main/java/stirling/software/SPDF/utils/PdfUtils.java index 59a6877e..225a2c12 100644 --- a/src/main/java/stirling/software/SPDF/utils/PdfUtils.java +++ b/src/main/java/stirling/software/SPDF/utils/PdfUtils.java @@ -342,8 +342,6 @@ public class PdfUtils { boolean imageIsLandscape = image.getWidth() > image.getHeight(); PDRectangle pageSize = PDRectangle.A4; - System.out.println(fitOption); - if (autoRotate && imageIsLandscape) { pageSize = new PDRectangle(pageSize.getHeight(), pageSize.getWidth()); } diff --git a/src/main/resources/templates/fragments/navbar.html b/src/main/resources/templates/fragments/navbar.html index 306eaed8..8b412a6b 100644 --- a/src/main/resources/templates/fragments/navbar.html +++ b/src/main/resources/templates/fragments/navbar.html @@ -17,20 +17,20 @@