From a3374745f849a6ac2ae7d9b1a9c4780119fec0e9 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com.> Date: Thu, 8 Aug 2024 21:13:59 +0100 Subject: [PATCH] formatting --- Dockerfile | 4 +- Dockerfile-fat | 4 +- build.gradle | 2 +- .../software/SPDF/SPdfApplication.java | 3 +- .../api/PdfImageRemovalController.java | 12 ++--- .../api/misc/ExtractImagesController.java | 45 ++++++++++--------- .../SPDF/service/PdfImageRemovalService.java | 8 ++-- 7 files changed, 40 insertions(+), 38 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3e257f1d..44031ba7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,8 +45,8 @@ RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /et # CV py3-opencv \ # python3/pip - python3 && \ - wget https://bootstrap.pypa.io/get-pip.py -qO - | python3 - --break-system-packages --no-cache-dir --upgrade && \ + python3 \ + py3-pip && \ # uno unoconv and HTML pip install --break-system-packages --no-cache-dir --upgrade unoconv WeasyPrint && \ mv /usr/share/tessdata /usr/share/tessdata-original && \ diff --git a/Dockerfile-fat b/Dockerfile-fat index 94d3d73b..c31fe348 100644 --- a/Dockerfile-fat +++ b/Dockerfile-fat @@ -61,8 +61,8 @@ RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/main" | tee -a /et # CV py3-opencv \ # python3/pip - python3 && \ - wget https://bootstrap.pypa.io/get-pip.py -qO - | python3 - --break-system-packages --no-cache-dir --upgrade && \ + python3 \ + py3-pip && \ # uno unoconv and HTML pip install --break-system-packages --no-cache-dir --upgrade unoconv WeasyPrint && \ mv /usr/share/tessdata /usr/share/tessdata-original && \ diff --git a/build.gradle b/build.gradle index 07abc000..12780703 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ ext { } group = "stirling.software" -version = "0.26.2" +version = "0.27.0" java { // 17 is lowest but we support and recommend 21 diff --git a/src/main/java/stirling/software/SPDF/SPdfApplication.java b/src/main/java/stirling/software/SPDF/SPdfApplication.java index 3b4ea174..3410b950 100644 --- a/src/main/java/stirling/software/SPDF/SPdfApplication.java +++ b/src/main/java/stirling/software/SPDF/SPdfApplication.java @@ -78,7 +78,8 @@ public class SPdfApplication { // custom javs settings file if (Files.exists(Paths.get("configs/custom_settings.yml"))) { - String existingLocation = propertyFiles.getOrDefault("spring.config.additional-location", ""); + String existingLocation = + propertyFiles.getOrDefault("spring.config.additional-location", ""); if (!existingLocation.isEmpty()) { existingLocation += ","; } diff --git a/src/main/java/stirling/software/SPDF/controller/api/PdfImageRemovalController.java b/src/main/java/stirling/software/SPDF/controller/api/PdfImageRemovalController.java index a3b9e93c..d56b7d2d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/PdfImageRemovalController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/PdfImageRemovalController.java @@ -16,10 +16,9 @@ import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.service.PdfImageRemovalService; import stirling.software.SPDF.utils.WebResponseUtils; - /** - * Controller class for handling PDF image removal requests. - * Provides an endpoint to remove images from a PDF file to reduce its size. + * Controller class for handling PDF image removal requests. Provides an endpoint to remove images + * from a PDF file to reduce its size. */ @RestController @RequestMapping("/api/v1/general") @@ -40,11 +39,12 @@ public class PdfImageRemovalController { /** * Endpoint to remove images from a PDF file. * - * This method processes the uploaded PDF file, removes all images, and returns - * the modified PDF file with a new name indicating that images were removed. + *
This method processes the uploaded PDF file, removes all images, and returns the modified + * PDF file with a new name indicating that images were removed. * * @param file The PDF file with images to be removed. - * @return ResponseEntity containing the modified PDF file as byte array with appropriate content type and filename. + * @return ResponseEntity containing the modified PDF file as byte array with appropriate + * content type and filename. * @throws IOException If an error occurs while processing the PDF file. */ @PostMapping(consumes = "multipart/form-data", value = "/remove-image-pdf") diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImagesController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImagesController.java index 7fe27a03..dcbc00aa 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImagesController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImagesController.java @@ -1,26 +1,5 @@ package stirling.software.SPDF.controller.api.misc; -import io.github.pixee.security.Filenames; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.apache.pdfbox.Loader; -import org.apache.pdfbox.cos.COSName; -import org.apache.pdfbox.pdmodel.PDDocument; -import org.apache.pdfbox.pdmodel.PDPage; -import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.MediaType; -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 stirling.software.SPDF.model.api.PDFWithImageFormatRequest; -import stirling.software.SPDF.utils.WebResponseUtils; - -import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.awt.image.RenderedImage; @@ -36,6 +15,30 @@ import java.util.zip.Deflater; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import javax.imageio.ImageIO; + +import org.apache.pdfbox.Loader; +import org.apache.pdfbox.cos.COSName; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.pdmodel.PDPage; +import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.MediaType; +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.github.pixee.security.Filenames; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import stirling.software.SPDF.model.api.PDFWithImageFormatRequest; +import stirling.software.SPDF.utils.WebResponseUtils; + @RestController @RequestMapping("/api/v1/misc") @Tag(name = "Misc", description = "Miscellaneous APIs") diff --git a/src/main/java/stirling/software/SPDF/service/PdfImageRemovalService.java b/src/main/java/stirling/software/SPDF/service/PdfImageRemovalService.java index 052d9977..985d1f48 100644 --- a/src/main/java/stirling/software/SPDF/service/PdfImageRemovalService.java +++ b/src/main/java/stirling/software/SPDF/service/PdfImageRemovalService.java @@ -9,17 +9,15 @@ import org.apache.pdfbox.pdmodel.PDResources; import org.apache.pdfbox.pdmodel.graphics.PDXObject; import org.springframework.stereotype.Service; -/** - * Service class responsible for removing image objects from a PDF document. - */ +/** Service class responsible for removing image objects from a PDF document. */ @Service public class PdfImageRemovalService { /** * Removes all image objects from the provided PDF document. * - * This method iterates over each page in the document and removes any - * image XObjects found in the page's resources. + * This method iterates over each page in the document and removes any image XObjects found + * in the page's resources. * * @param document The PDF document from which images will be removed. * @return The modified PDF document with images removed.