From b1fd798a5cbf02fd9f804103dd6a3df602477659 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sat, 9 Sep 2023 00:25:27 +0100 Subject: [PATCH 01/13] init --- build.gradle | 2 + .../SPDF/controller/api/CropController.java | 19 ++++---- .../SPDF/controller/api/MergeController.java | 19 +++----- .../api/MultiPageLayoutController.java | 11 +++-- .../api/RearrangePagesPDFController.java | 32 +++++-------- .../controller/api/RotationController.java | 12 ++--- .../controller/api/ScalePagesController.java | 14 +++--- .../controller/api/SplitPDFController.java | 31 +++--------- .../api/ToSinglePageController.java | 11 ++--- .../api/converters/ConvertEpubToPdf.java | 7 ++- .../api/converters/ConvertHtmlToPDF.java | 6 ++- .../converters/ConvertImgPDFController.java | 46 +++++++----------- .../api/converters/ConvertMarkdownToPdf.java | 7 ++- .../converters/ConvertOfficeController.java | 13 ++--- .../api/converters/ConvertPDFToOffice.java | 43 +++++++++-------- .../api/converters/ConvertPDFToPDFA.java | 9 ++-- .../api/converters/ConvertWebsiteToPDF.java | 8 ++-- .../other/ExtractImageScansController.java | 48 ++++++++----------- .../SPDF/controller/api/other/MyForm.java | 27 +++++++++++ .../api/security/CertSignController.java | 2 +- .../software/SPDF/model/SortTypes.java | 4 ++ .../software/SPDF/model/api/GeneralFile.java | 13 +++++ .../software/SPDF/model/api/ImageFile.java | 12 +++++ .../SPDF/model/api/MultiplePDFFiles.java | 11 +++++ .../software/SPDF/model/api/PDFFile.java | 11 +++++ .../SPDF/model/api/PDFWithPageNums.java | 36 ++++++++++++++ .../api/converters/ConvertToImageRequest.java | 22 +++++++++ .../api/converters/ConvertToPdfRequest.java | 21 ++++++++ .../converters/PdfToPresentationRequest.java | 13 +++++ .../api/converters/PdfToTextOrRTFRequest.java | 12 +++++ .../api/converters/PdfToWordRequest.java | 12 +++++ .../model/api/converters/UrlToPdfRequest.java | 11 +++++ .../SPDF/model/api/general/CropPdfForm.java | 26 ++++++++++ .../general/MergeMultiplePagesRequest.java | 13 +++++ .../model/api/general/MergePdfsRequest.java | 20 ++++++++ .../api/general/RearrangePagesRequest.java | 23 +++++++++ .../model/api/general/RotatePDFRequest.java | 13 +++++ .../model/api/general/ScalePagesRequest.java | 20 ++++++++ .../software/SPDF/utils/GeneralUtils.java | 3 ++ 39 files changed, 468 insertions(+), 195 deletions(-) create mode 100644 src/main/java/stirling/software/SPDF/controller/api/other/MyForm.java create mode 100644 src/main/java/stirling/software/SPDF/model/SortTypes.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/GeneralFile.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/ImageFile.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/MultiplePDFFiles.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/PDFFile.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/PDFWithPageNums.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/converters/ConvertToImageRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/converters/ConvertToPdfRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/converters/PdfToPresentationRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/converters/PdfToTextOrRTFRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/converters/PdfToWordRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/converters/UrlToPdfRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/general/CropPdfForm.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/general/MergeMultiplePagesRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/general/MergePdfsRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/general/RearrangePagesRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/general/RotatePDFRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/general/ScalePagesRequest.java diff --git a/build.gradle b/build.gradle index b628a2d4..bc62189e 100644 --- a/build.gradle +++ b/build.gradle @@ -98,6 +98,8 @@ dependencies { implementation 'com.github.vladimir-bukhtoyarov:bucket4j-core:7.6.0' developmentOnly("org.springframework.boot:spring-boot-devtools") + compileOnly 'org.projectlombok:lombok:1.18.28' + annotationProcessor 'org.projectlombok:lombok:1.18.28' } diff --git a/src/main/java/stirling/software/SPDF/controller/api/CropController.java b/src/main/java/stirling/software/SPDF/controller/api/CropController.java index 9e8cf1fe..38d68420 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/CropController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/CropController.java @@ -13,6 +13,7 @@ import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -22,6 +23,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.general.CropPdfForm; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @@ -32,18 +34,13 @@ public class CropController { @PostMapping(value = "/crop", consumes = "multipart/form-data") @Operation(summary = "Crops a PDF document", description = "This operation takes an input PDF file and crops it according to the given coordinates. Input:PDF Output:PDF Type:SISO") - public ResponseEntity cropPdf( - @Parameter(description = "The input PDF file", required = true) @RequestParam("fileInput") MultipartFile file, - @Parameter(description = "The x-coordinate of the top-left corner of the crop area", required = true, schema = @Schema(type = "number")) @RequestParam("x") float x, - @Parameter(description = "The y-coordinate of the top-left corner of the crop area", required = true, schema = @Schema(type = "number")) @RequestParam("y") float y, - @Parameter(description = "The width of the crop area", required = true, schema = @Schema(type = "number")) @RequestParam("width") float width, - @Parameter(description = "The height of the crop area", required = true, schema = @Schema(type = "number")) @RequestParam("height") float height) + public ResponseEntity cropPdf(@ModelAttribute CropPdfForm form) throws IOException { + - -PDDocument sourceDocument = PDDocument.load(new ByteArrayInputStream(file.getBytes())); +PDDocument sourceDocument = PDDocument.load(new ByteArrayInputStream(form.getFileInput().getBytes())); PDDocument newDocument = new PDDocument(); @@ -65,7 +62,7 @@ for (int i = 0; i < totalPages; i++) { contentStream.saveGraphicsState(); // Define the crop area - contentStream.addRect(x, y, width, height); + contentStream.addRect(form.getX(), form.getY(), form.getWidth(), form.getHeight()); contentStream.clip(); // Draw the entire formXObject @@ -76,7 +73,7 @@ for (int i = 0; i < totalPages; i++) { contentStream.close(); // Now, set the new page's media box to the cropped size - newPage.setMediaBox(new PDRectangle(x, y, width, height)); + newPage.setMediaBox(new PDRectangle(form.getX(), form.getY(), form.getWidth(), form.getHeight())); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -85,7 +82,7 @@ newDocument.close(); sourceDocument.close(); byte[] pdfContent = baos.toByteArray(); -return WebResponseUtils.bytesToWebResponse(pdfContent, file.getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_cropped.pdf"); +return WebResponseUtils.bytesToWebResponse(pdfContent, form.getFileInput().getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_cropped.pdf"); } } diff --git a/src/main/java/stirling/software/SPDF/controller/api/MergeController.java b/src/main/java/stirling/software/SPDF/controller/api/MergeController.java index e51db38e..03bf4066 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/MergeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/MergeController.java @@ -15,6 +15,7 @@ import org.apache.pdfbox.pdmodel.PDPage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -25,6 +26,8 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.general.CropPdfForm; +import stirling.software.SPDF.model.api.general.MergePdfsRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @@ -88,20 +91,10 @@ private Comparator getSortComparator(String sortType) { @PostMapping(consumes = "multipart/form-data", value = "/merge-pdfs") @Operation(summary = "Merge multiple PDF files into one", description = "This endpoint merges multiple PDF files into a single PDF file. The merged file will contain all pages from the input files in the order they were provided. Input:PDF Output:PDF Type:MISO") -public ResponseEntity mergePdfs( - @RequestPart(required = true, value = "fileInput") MultipartFile[] files, - @RequestParam(value = "sortType", defaultValue = "orderProvided") - @Parameter(schema = @Schema(description = "The type of sorting to be applied on the input files before merging.", - allowableValues = { - "orderProvided", - "byFileName", - "byDateModified", - "byDateCreated", - "byPDFTitle" - })) - String sortType) throws IOException { +public ResponseEntity mergePdfs(@ModelAttribute MergePdfsRequest form) throws IOException { - Arrays.sort(files, getSortComparator(sortType)); + MultipartFile[] files = form.getFileInput(); + Arrays.sort(files, getSortComparator(form.getSortType())); List documents = new ArrayList<>(); for (MultipartFile file : files) { diff --git a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java index 738542a0..12c262cd 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java @@ -14,6 +14,7 @@ import org.apache.pdfbox.util.Matrix; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -23,6 +24,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.general.MergeMultiplePagesRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @@ -36,12 +38,11 @@ public class MultiPageLayoutController { summary = "Merge multiple pages of a PDF document into a single page", description = "This operation takes an input PDF file and the number of pages to merge into a single sheet in the output PDF file. Input:PDF Output:PDF Type:SISO" ) - public ResponseEntity mergeMultiplePagesIntoOne( - @Parameter(description = "The input PDF file", required = true) @RequestParam("fileInput") MultipartFile file, - @Parameter(description = "The number of pages to fit onto a single sheet in the output PDF. Acceptable values are 2, 3, 4, 9, 16.", required = true, schema = @Schema(type = "integer", allowableValues = { - "2", "3", "4", "9", "16" })) @RequestParam("pagesPerSheet") int pagesPerSheet) + public ResponseEntity mergeMultiplePagesIntoOne(@ModelAttribute MergeMultiplePagesRequest request) throws IOException { - + + int pagesPerSheet = request.getPagesPerSheet(); + MultipartFile file = request.getFileInput(); if (pagesPerSheet != 2 && pagesPerSheet != 3 && pagesPerSheet != (int) Math.sqrt(pagesPerSheet) * Math.sqrt(pagesPerSheet)) { throw new IllegalArgumentException("pagesPerSheet must be 2, 3 or a perfect square"); } diff --git a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java index 78df1f41..294df38d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java @@ -9,6 +9,7 @@ import org.apache.pdfbox.pdmodel.PDPage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -21,7 +22,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.GeneralUtils; import stirling.software.SPDF.utils.WebResponseUtils; - +import stirling.software.SPDF.model.SortTypes; +import stirling.software.SPDF.model.api.general.RearrangePagesRequest; @RestController @Tag(name = "General", description = "General APIs") public class RearrangePagesPDFController { @@ -51,9 +53,7 @@ public class RearrangePagesPDFController { } - private enum CustomMode { - REVERSE_ORDER, DUPLEX_SORT, BOOKLET_SORT, SIDE_STITCH_BOOKLET_SORT, ODD_EVEN_SPLIT, REMOVE_FIRST, REMOVE_LAST, REMOVE_FIRST_AND_LAST, - } + private List removeFirst(int totalPages) { if (totalPages <= 1) @@ -137,9 +137,9 @@ public class RearrangePagesPDFController { return newPageOrder; } - private List processCustomMode(String customMode, int totalPages) { + private List processSortTypes(String sortTypes, int totalPages) { try { - CustomMode mode = CustomMode.valueOf(customMode.toUpperCase()); + SortTypes mode = SortTypes.valueOf(sortTypes.toUpperCase()); switch (mode) { case REVERSE_ORDER: return reverseOrder(totalPages); @@ -168,16 +168,10 @@ public class RearrangePagesPDFController { @PostMapping(consumes = "multipart/form-data", value = "/rearrange-pages") @Operation(summary = "Rearrange pages in a PDF file", description = "This endpoint rearranges pages in a given PDF file based on the specified page order or custom mode. Users can provide a page order as a comma-separated list of page numbers or page ranges, or a custom mode. Input:PDF Output:PDF") - public ResponseEntity rearrangePages( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file to rearrange pages") MultipartFile pdfFile, - @RequestParam(required = false, value = "pageOrder") @Parameter(description = "The new page order as a comma-separated list of page numbers, page ranges (e.g., '1,3,5-7'), or functions in the format 'an+b' where 'a' is the multiplier of the page number 'n', and 'b' is a constant (e.g., '2n+1', '3n', '6n-5')") String pageOrder, - @RequestParam(required = false, value = "customMode") @Parameter(schema = @Schema(implementation = CustomMode.class, description = "The custom mode for page rearrangement. " - + "Valid values are:\n" + "REVERSE_ORDER: Reverses the order of all pages.\n" - + "DUPLEX_SORT: Sorts pages as if all fronts were scanned then all backs in reverse (1, n, 2, n-1, ...). " - + "BOOKLET_SORT: Arranges pages for booklet printing (last, first, second, second last, ...).\n" - + "ODD_EVEN_SPLIT: Splits and arranges pages into odd and even numbered pages.\n" - + "REMOVE_FIRST: Removes the first page.\n" + "REMOVE_LAST: Removes the last page.\n" - + "REMOVE_FIRST_AND_LAST: Removes both the first and the last pages.\n")) String customMode) { + public ResponseEntity rearrangePages(@ModelAttribute RearrangePagesRequest request) throws IOException { + MultipartFile pdfFile = request.getFileInput(); + String pageOrder = request.getPageNumbers(); + String sortType = request.getCustomMode(); try { // Load the input PDF PDDocument document = PDDocument.load(pdfFile.getInputStream()); @@ -186,10 +180,10 @@ public class RearrangePagesPDFController { String[] pageOrderArr = pageOrder != null ? pageOrder.split(",") : new String[0]; int totalPages = document.getNumberOfPages(); System.out.println("pageOrder=" + pageOrder); - System.out.println("customMode length =" + customMode.length()); + System.out.println("SortTypes length =" + sortType.length()); List newPageOrder; - if (customMode != null && customMode.length() > 0) { - newPageOrder = processCustomMode(customMode, totalPages); + if (sortType != null && sortType.length() > 0) { + newPageOrder = processSortTypes(sortType, totalPages); } else { newPageOrder = GeneralUtils.parsePageList(pageOrderArr, totalPages); } diff --git a/src/main/java/stirling/software/SPDF/controller/api/RotationController.java b/src/main/java/stirling/software/SPDF/controller/api/RotationController.java index 916d2afb..ef32df4e 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RotationController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RotationController.java @@ -8,6 +8,7 @@ import org.apache.pdfbox.pdmodel.PDPageTree; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -17,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.general.RotatePDFRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @@ -31,13 +33,9 @@ public class RotationController { description = "This endpoint rotates a given PDF file by a specified angle. The angle must be a multiple of 90. Input:PDF Output:PDF Type:SISO" ) public ResponseEntity rotatePDF( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The PDF file to be rotated", required = true) - MultipartFile pdfFile, - @RequestParam("angle") - @Parameter(description = "The angle by which to rotate the PDF file. This should be a multiple of 90.", example = "90", required = true) - Integer angle) throws IOException { - + @ModelAttribute RotatePDFRequest request) throws IOException { + MultipartFile pdfFile = request.getFileInput(); + Integer angle = request.getAngle(); // Load the PDF document PDDocument document = PDDocument.load(pdfFile.getBytes()); diff --git a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java index 2f1cde7d..2dcb26af 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java @@ -15,6 +15,7 @@ import org.apache.pdfbox.util.Matrix; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -24,6 +25,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.general.ScalePagesRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @Tag(name = "General", description = "General APIs") @@ -33,14 +35,10 @@ public class ScalePagesController { @PostMapping(value = "/scale-pages", consumes = "multipart/form-data") @Operation(summary = "Change the size of a PDF page/document", description = "This operation takes an input PDF file and the size to scale the pages to in the output PDF file. Input:PDF Output:PDF Type:SISO") - public ResponseEntity scalePages( - @Parameter(description = "The input PDF file", required = true) @RequestParam("fileInput") MultipartFile file, - @Parameter(description = "The scale of pages in the output PDF. Acceptable values are A0-A10, B0-B9, LETTER, TABLOID, LEDGER, LEGAL, EXECUTIVE.", required = true, schema = @Schema(type = "string", allowableValues = { - "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "B0", "B1", "B2", "B3", "B4", - "B5", "B6", "B7", "B8", "B9", "LETTER", "TABLOID", "LEDGER", "LEGAL", - "EXECUTIVE" })) @RequestParam("pageSize") String targetPDRectangle, - @Parameter(description = "The scale of the content on the pages of the output PDF. Acceptable values are floats.", required = true, schema = @Schema(type = "integer")) @RequestParam("scaleFactor") float scaleFactor) - throws IOException { + public ResponseEntity scalePages(@ModelAttribute ScalePagesRequest request) throws IOException { + MultipartFile file = request.getFileInput(); + String targetPDRectangle = request.getTargetPDRectangle(); + float scaleFactor = request.getScaleFactor(); Map sizeMap = new HashMap<>(); // Add A0 - A10 diff --git a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java index abc201ab..fe3a1cc5 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java @@ -17,6 +17,7 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -26,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.PDFWithPageNums; import stirling.software.SPDF.utils.GeneralUtils; import stirling.software.SPDF.utils.WebResponseUtils; @@ -38,35 +40,14 @@ public class SplitPDFController { @PostMapping(consumes = "multipart/form-data", value = "/split-pages") @Operation(summary = "Split a PDF file into separate documents", description = "This endpoint splits a given PDF file into separate documents based on the specified page numbers or ranges. Users can specify pages using individual numbers, ranges, or 'all' for every page. Input:PDF Output:PDF Type:SIMO") - public ResponseEntity splitPdf( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file to be split") - MultipartFile file, - @RequestParam("pages") - @Parameter(description = "The pages to be included in separate documents. Specify individual page numbers (e.g., '1,3,5'), ranges (e.g., '1-3,5-7'), or 'all' for every page.") - String pages) throws IOException { - // parse user input - + public ResponseEntity splitPdf(@ModelAttribute PDFWithPageNums request) throws IOException { + MultipartFile file = request.getFileInput(); + String pages = request.getPageNumbers(); // open the pdf document InputStream inputStream = file.getInputStream(); PDDocument document = PDDocument.load(inputStream); - List pageNumbers = new ArrayList<>(); - pages = pages.replaceAll("\\s+", ""); // remove whitespaces - if (pages.toLowerCase().equals("all")) { - for (int i = 0; i < document.getNumberOfPages(); i++) { - pageNumbers.add(i); - } - } else { - String[] splitPoints = pages.split(","); - for (String splitPoint : splitPoints) { - List orderedPages = GeneralUtils.parsePageList(new String[] {splitPoint}, document.getNumberOfPages()); - pageNumbers.addAll(orderedPages); - } - // Add the last page as a split point - pageNumbers.add(document.getNumberOfPages() - 1); - } - + List pageNumbers = request.getPageNumbersList(document); logger.info("Splitting PDF into pages: {}", pageNumbers.stream().map(String::valueOf).collect(Collectors.joining(","))); // split the document diff --git a/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java b/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java index e46cb55a..ea64d55b 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java @@ -13,6 +13,7 @@ import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -21,6 +22,7 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @Tag(name = "General", description = "General APIs") @@ -34,13 +36,10 @@ public class ToSinglePageController { summary = "Convert a multi-page PDF into a single long page PDF", description = "This endpoint converts a multi-page PDF document into a single paged PDF document. The width of the single page will be same as the input's width, but the height will be the sum of all the pages' heights. Input:PDF Output:PDF Type:SISO" ) - public ResponseEntity pdfToSinglePage( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input multi-page PDF file to be converted into a single page", required = true) - MultipartFile file) throws IOException { + public ResponseEntity pdfToSinglePage(@ModelAttribute PDFFile request) throws IOException { // Load the source document - PDDocument sourceDocument = PDDocument.load(file.getInputStream()); + PDDocument sourceDocument = PDDocument.load(request.getFileInput().getInputStream()); // Calculate total height and max width float totalHeight = 0; @@ -79,7 +78,7 @@ public class ToSinglePageController { sourceDocument.close(); byte[] result = baos.toByteArray(); - return WebResponseUtils.bytesToWebResponse(result, file.getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_singlePage.pdf"); + return WebResponseUtils.bytesToWebResponse(result, request.getFileInput().getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_singlePage.pdf"); diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java index 21f4612b..77262cce 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java @@ -14,6 +14,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -26,6 +27,8 @@ import org.xml.sax.InputSource; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.GeneralFile; +import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.FileToPdf; import stirling.software.SPDF.utils.WebResponseUtils; @@ -40,9 +43,9 @@ public class ConvertEpubToPdf { description = "This endpoint takes an EPUB file input and converts it to a single PDF." ) public ResponseEntity epubToSinglePdf( - @RequestPart(required = true, value = "fileInput") MultipartFile fileInput) + @ModelAttribute GeneralFile request) throws Exception { - + MultipartFile fileInput = request.getFileInput(); if (fileInput == null) { throw new IllegalArgumentException("Please provide an EPUB file for conversion."); } diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java index 762cbe6b..d9308d09 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java @@ -3,6 +3,7 @@ package stirling.software.SPDF.controller.api.converters; import java.io.IOException; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -10,6 +11,7 @@ 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.GeneralFile; import stirling.software.SPDF.utils.FileToPdf; import stirling.software.SPDF.utils.WebResponseUtils; @@ -24,7 +26,9 @@ public class ConvertHtmlToPDF { description = "This endpoint takes an HTML or ZIP file input and converts it to a PDF format." ) public ResponseEntity HtmlToPdf( - @RequestPart(required = true, value = "fileInput") MultipartFile fileInput) throws IOException, InterruptedException { + @ModelAttribute GeneralFile request) + throws Exception { + MultipartFile fileInput = request.getFileInput(); if (fileInput == null) { throw new IllegalArgumentException("Please provide an HTML or ZIP file for conversion."); diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java index d4964196..5a4dab2c 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java @@ -11,6 +11,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -21,6 +22,8 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.converters.ConvertToImageRequest; +import stirling.software.SPDF.model.api.converters.ConvertToPdfRequest; import stirling.software.SPDF.utils.PdfUtils; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @@ -32,23 +35,13 @@ public class ConvertImgPDFController { @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-img") @Operation(summary = "Convert PDF to image(s)", description = "This endpoint converts a PDF file to image(s) with the specified image format, color type, and DPI. Users can choose to get a single image or multiple images. Input:PDF Output:Image Type:SI-Conditional") - public ResponseEntity convertToImage( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file to be converted") - MultipartFile file, - @RequestParam("imageFormat") - @Parameter(description = "The output image format", schema = @Schema(allowableValues = {"png", "jpeg", "jpg", "gif"})) - String imageFormat, - @RequestParam("singleOrMultiple") - @Parameter(description = "Choose between a single image containing all pages or separate images for each page", schema = @Schema(allowableValues = {"single", "multiple"})) - String singleOrMultiple, - @RequestParam("colorType") - @Parameter(description = "The color type of the output image(s)", schema = @Schema(allowableValues = {"color", "greyscale", "blackwhite"})) - String colorType, - @RequestParam("dpi") - @Parameter(description = "The DPI (dots per inch) for the output image(s)") - String dpi) throws IOException { - + public ResponseEntity convertToImage(@ModelAttribute ConvertToImageRequest request) throws IOException { + MultipartFile file = request.getFileInput(); + String imageFormat = request.getImageFormat(); + String singleOrMultiple = request.getSingleOrMultiple(); + String colorType = request.getColorType(); + String dpi = request.getDpi(); + byte[] pdfBytes = file.getBytes(); ImageType colorTypeResult = ImageType.RGB; if ("greyscale".equals(colorType)) { @@ -86,19 +79,12 @@ public class ConvertImgPDFController { @PostMapping(consumes = "multipart/form-data", value = "/img-to-pdf") @Operation(summary = "Convert images to a PDF file", description = "This endpoint converts one or more images to a PDF file. Users can specify whether to stretch the images to fit the PDF page, and whether to automatically rotate the images. Input:Image Output:PDF Type:SISO?") - public ResponseEntity convertToPdf( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input images to be converted to a PDF file") - MultipartFile[] file, - @RequestParam(defaultValue = "false", name = "stretchToFit") - @Parameter(description = "Whether to stretch the images to fit the PDF page or maintain the aspect ratio", example = "false") - boolean stretchToFit, - @RequestParam("colorType") - @Parameter(description = "The color type of the output image(s)", schema = @Schema(allowableValues = {"color", "greyscale", "blackwhite"})) - String colorType, - @RequestParam(defaultValue = "false", name = "autoRotate") - @Parameter(description = "Whether to automatically rotate the images to better fit the PDF page", example = "true") - boolean autoRotate) throws IOException { + public ResponseEntity convertToPdf(@ModelAttribute ConvertToPdfRequest request) throws IOException { + MultipartFile[] file = request.getFileInput(); + boolean stretchToFit = request.isStretchToFit(); + String colorType = request.getColorType(); + boolean autoRotate = request.isAutoRotate(); + // Convert the file to PDF and get the resulting bytes byte[] bytes = PdfUtils.imageToPdf(file, stretchToFit, autoRotate, colorType); return WebResponseUtils.bytesToWebResponse(bytes, file[0].getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_converted.pdf"); diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java index c1bc1b73..02ff1e27 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java @@ -6,6 +6,7 @@ import org.commonmark.node.Node; import org.commonmark.parser.Parser; import org.commonmark.renderer.html.HtmlRenderer; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -13,6 +14,7 @@ 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.GeneralFile; import stirling.software.SPDF.utils.FileToPdf; import stirling.software.SPDF.utils.WebResponseUtils; @@ -26,8 +28,9 @@ public class ConvertMarkdownToPdf { description = "This endpoint takes a Markdown file input, converts it to HTML, and then to PDF format." ) public ResponseEntity markdownToPdf( - @RequestPart(required = true, value = "fileInput") MultipartFile fileInput) - throws IOException, InterruptedException { + @ModelAttribute GeneralFile request) + throws Exception { + MultipartFile fileInput = request.getFileInput(); if (fileInput == null) { throw new IllegalArgumentException("Please provide a Markdown file for conversion."); diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java index 3b9f278f..9ee5cdd5 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java @@ -10,6 +10,7 @@ import java.util.List; import org.apache.commons.io.FilenameUtils; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -18,6 +19,7 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.GeneralFile; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; @@ -63,14 +65,9 @@ public class ConvertOfficeController { summary = "Convert a file to a PDF using LibreOffice", description = "This endpoint converts a given file to a PDF using LibreOffice API Input:Any Output:PDF Type:SISO" ) - public ResponseEntity processFileToPDF( - @RequestPart(required = true, value = "fileInput") - @Parameter( - description = "The input file to be converted to a PDF file using LibreOffice", - required = true - ) - MultipartFile inputFile - ) throws IOException, InterruptedException { + public ResponseEntity processFileToPDF(@ModelAttribute GeneralFile request) + throws Exception { + MultipartFile inputFile = request.getFileInput(); // unused but can start server instance if startup time is to long // LibreOfficeListener.getInstance().start(); diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java index 7c99ee4d..b61549ff 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java @@ -3,6 +3,7 @@ package stirling.software.SPDF.controller.api.converters; import java.io.IOException; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -13,6 +14,11 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.GeneralFile; +import stirling.software.SPDF.model.api.PDFFile; +import stirling.software.SPDF.model.api.converters.PdfToPresentationRequest; +import stirling.software.SPDF.model.api.converters.PdfToTextOrRTFRequest; +import stirling.software.SPDF.model.api.converters.PdfToWordRequest; import stirling.software.SPDF.utils.PDFToFile; @RestController @@ -21,51 +27,46 @@ public class ConvertPDFToOffice { @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-html") @Operation(summary = "Convert PDF to HTML", description = "This endpoint converts a PDF file to HTML format. Input:PDF Output:HTML Type:SISO") - public ResponseEntity processPdfToHTML( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file to be converted to HTML format", required = true) MultipartFile inputFile) - throws IOException, InterruptedException { + public ResponseEntity processPdfToHTML(@ModelAttribute PDFFile request) + throws Exception { + MultipartFile inputFile = request.getFileInput(); PDFToFile pdfToFile = new PDFToFile(); return pdfToFile.processPdfToOfficeFormat(inputFile, "html", "writer_pdf_import"); } @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-presentation") @Operation(summary = "Convert PDF to Presentation format", description = "This endpoint converts a given PDF file to a Presentation format. Input:PDF Output:PPT Type:SISO") - public ResponseEntity processPdfToPresentation( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file") MultipartFile inputFile, - @RequestParam("outputFormat") @Parameter(description = "The output Presentation format", schema = @Schema(allowableValues = { - "ppt", "pptx", "odp" })) String outputFormat) - throws IOException, InterruptedException { + public ResponseEntity processPdfToPresentation(@ModelAttribute PdfToPresentationRequest request) throws IOException, InterruptedException { + MultipartFile inputFile = request.getFileInput(); + String outputFormat = request.getOutputFormat(); PDFToFile pdfToFile = new PDFToFile(); return pdfToFile.processPdfToOfficeFormat(inputFile, outputFormat, "impress_pdf_import"); } @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-text") @Operation(summary = "Convert PDF to Text or RTF format", description = "This endpoint converts a given PDF file to Text or RTF format. Input:PDF Output:TXT Type:SISO") - public ResponseEntity processPdfToRTForTXT( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file") MultipartFile inputFile, - @RequestParam("outputFormat") @Parameter(description = "The output Text or RTF format", schema = @Schema(allowableValues = { - "rtf", "txt:Text" })) String outputFormat) - throws IOException, InterruptedException { + public ResponseEntity processPdfToRTForTXT(@ModelAttribute PdfToTextOrRTFRequest request) throws IOException, InterruptedException { + MultipartFile inputFile = request.getFileInput(); + String outputFormat = request.getOutputFormat(); + PDFToFile pdfToFile = new PDFToFile(); return pdfToFile.processPdfToOfficeFormat(inputFile, outputFormat, "writer_pdf_import"); } @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-word") @Operation(summary = "Convert PDF to Word document", description = "This endpoint converts a given PDF file to a Word document format. Input:PDF Output:WORD Type:SISO") - public ResponseEntity processPdfToWord( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file") MultipartFile inputFile, - @RequestParam("outputFormat") @Parameter(description = "The output Word document format", schema = @Schema(allowableValues = { - "doc", "docx", "odt" })) String outputFormat) - throws IOException, InterruptedException { + public ResponseEntity processPdfToWord(@ModelAttribute PdfToWordRequest request) throws IOException, InterruptedException { + MultipartFile inputFile = request.getFileInput(); + String outputFormat = request.getOutputFormat(); PDFToFile pdfToFile = new PDFToFile(); return pdfToFile.processPdfToOfficeFormat(inputFile, outputFormat, "writer_pdf_import"); } @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-xml") @Operation(summary = "Convert PDF to XML", description = "This endpoint converts a PDF file to an XML file. Input:PDF Output:XML Type:SISO") - public ResponseEntity processPdfToXML( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file to be converted to an XML file", required = true) MultipartFile inputFile) - throws IOException, InterruptedException { + public ResponseEntity processPdfToXML(@ModelAttribute PDFFile request) + throws Exception { + MultipartFile inputFile = request.getFileInput(); PDFToFile pdfToFile = new PDFToFile(); return pdfToFile.processPdfToOfficeFormat(inputFile, "xml", "writer_pdf_import"); diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java index 6a99090b..ca83d4ed 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.List; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -15,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; @@ -28,10 +30,9 @@ public class ConvertPDFToPDFA { summary = "Convert a PDF to a PDF/A", description = "This endpoint converts a PDF file to a PDF/A file. PDF/A is a format designed for long-term archiving of digital documents. Input:PDF Output:PDF Type:SISO" ) - public ResponseEntity pdfToPdfA( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file to be converted to a PDF/A file", required = true) - MultipartFile inputFile) throws IOException, InterruptedException { + public ResponseEntity pdfToPdfA(@ModelAttribute PDFFile request) + throws Exception { + MultipartFile inputFile = request.getFileInput(); // Save the uploaded file to a temporary location Path tempInputFile = Files.createTempFile("input_", ".pdf"); diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java index 2268ead5..3d4fd368 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.List; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.converters.UrlToPdfRequest; import stirling.software.SPDF.utils.GeneralUtils; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; @@ -28,10 +30,8 @@ public class ConvertWebsiteToPDF { summary = "Convert a URL to a PDF", description = "This endpoint fetches content from a URL and converts it to a PDF format." ) - public ResponseEntity urlToPdf( - @RequestParam(required = true, value = "urlInput") - @Parameter(description = "The input URL to be converted to a PDF file", required = true) - String URL) throws IOException, InterruptedException { + public ResponseEntity urlToPdf(@ModelAttribute UrlToPdfRequest request) throws IOException, InterruptedException { + String URL = request.getUrlInput(); // Validate the URL format if(!URL.matches("^https?://.*") || !GeneralUtils.isValidURL(URL)) { diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImageScansController.java b/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImageScansController.java index 55ff446c..cb13682d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImageScansController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImageScansController.java @@ -30,12 +30,14 @@ 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.parameters.RequestBody; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; - +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; @RestController @Tag(name = "Other", description = "Other APIs") public class ExtractImageScansController { @@ -46,26 +48,16 @@ public class ExtractImageScansController { @Operation(summary = "Extract image scans from an input file", description = "This endpoint extracts image scans from a given file based on certain parameters. Users can specify angle threshold, tolerance, minimum area, minimum contour area, and border size. Input:PDF Output:IMAGE/ZIP Type:SIMO") public ResponseEntity extractImageScans( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input file containing image scans") - MultipartFile inputFile, - @RequestParam(name = "angle_threshold", defaultValue = "5") - @Parameter(description = "The angle threshold for the image scan extraction", example = "5") - int angleThreshold, - @RequestParam(name = "tolerance", defaultValue = "20") - @Parameter(description = "The tolerance for the image scan extraction", example = "20") - int tolerance, - @RequestParam(name = "min_area", defaultValue = "8000") - @Parameter(description = "The minimum area for the image scan extraction", example = "8000") - int minArea, - @RequestParam(name = "min_contour_area", defaultValue = "500") - @Parameter(description = "The minimum contour area for the image scan extraction", example = "500") - int minContourArea, - @RequestParam(name = "border_size", defaultValue = "1") - @Parameter(description = "The border size for the image scan extraction", example = "1") - int borderSize) throws IOException, InterruptedException { - - String fileName = inputFile.getOriginalFilename(); + @RequestBody( + description = "Form data containing file and extraction parameters", + required = true, + content = @Content( + mediaType = "multipart/form-data", + schema = @Schema(implementation = MyForm.class) // This should represent your form's structure + ) + ) + MyForm form) throws IOException, InterruptedException { + String fileName = form.getFileInput().getOriginalFilename(); String extension = fileName.substring(fileName.lastIndexOf(".") + 1); List images = new ArrayList<>(); @@ -73,7 +65,7 @@ public class ExtractImageScansController { // Check if input file is a PDF if (extension.equalsIgnoreCase("pdf")) { // Load PDF document - try (PDDocument document = PDDocument.load(new ByteArrayInputStream(inputFile.getBytes()))) { + try (PDDocument document = PDDocument.load(new ByteArrayInputStream(form.getFileInput().getBytes()))) { PDFRenderer pdfRenderer = new PDFRenderer(document); int pageCount = document.getNumberOfPages(); images = new ArrayList<>(); @@ -93,7 +85,7 @@ public class ExtractImageScansController { } } else { Path tempInputFile = Files.createTempFile("input_", "." + extension); - Files.copy(inputFile.getInputStream(), tempInputFile, StandardCopyOption.REPLACE_EXISTING); + Files.copy(form.getFileInput().getInputStream(), tempInputFile, StandardCopyOption.REPLACE_EXISTING); // Add input file path to images list images.add(tempInputFile.toString()); } @@ -109,11 +101,11 @@ public class ExtractImageScansController { "./scripts/split_photos.py", images.get(i), tempDir.toString(), - "--angle_threshold", String.valueOf(angleThreshold), - "--tolerance", String.valueOf(tolerance), - "--min_area", String.valueOf(minArea), - "--min_contour_area", String.valueOf(minContourArea), - "--border_size", String.valueOf(borderSize) + "--angle_threshold", String.valueOf(form.getAngleThreshold()), + "--tolerance", String.valueOf(form.getTolerance()), + "--min_area", String.valueOf(form.getMinArea()), + "--min_contour_area", String.valueOf(form.getMinContourArea()), + "--border_size", String.valueOf(form.getBorderSize()) )); diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/MyForm.java b/src/main/java/stirling/software/SPDF/controller/api/other/MyForm.java new file mode 100644 index 00000000..1938493a --- /dev/null +++ b/src/main/java/stirling/software/SPDF/controller/api/other/MyForm.java @@ -0,0 +1,27 @@ +package stirling.software.SPDF.controller.api.other; + +import org.springframework.web.multipart.MultipartFile; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class MyForm { + @Schema(description = "The input file containing image scans", required = true) + private MultipartFile fileInput; + + @Schema(description = "The angle threshold for the image scan extraction", defaultValue = "5", example = "5") + private int angleThreshold; + + @Schema(description = "The tolerance for the image scan extraction", defaultValue = "20", example = "20") + private int tolerance; + + @Schema(description = "The minimum area for the image scan extraction", defaultValue = "8000", example = "8000") + private int minArea; + + @Schema(description = "The minimum contour area for the image scan extraction", defaultValue = "500", example = "500") + private int minContourArea; + + @Schema(description = "The border size for the image scan extraction", defaultValue = "1", example = "1") + private int borderSize; +} 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 aaaf22b4..6392be96 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 @@ -69,7 +69,7 @@ public class CertSignController { @PostMapping(consumes = "multipart/form-data", value = "/cert-sign") @Operation(summary = "Sign PDF with a Digital Certificate", description = "This endpoint accepts a PDF file, a digital certificate and related information to sign the PDF. It then returns the digitally signed PDF file. Input:PDF Output:PDF Type:MF-SISO") public ResponseEntity signPDF2( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file to be signed") MultipartFile pdf, + @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file") MultipartFile pdf, @RequestParam(value = "certType", required = false) @Parameter(description = "The type of the digital certificate", schema = @Schema(allowableValues = { "PKCS12", "PEM" })) String certType, diff --git a/src/main/java/stirling/software/SPDF/model/SortTypes.java b/src/main/java/stirling/software/SPDF/model/SortTypes.java new file mode 100644 index 00000000..21181cfa --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/SortTypes.java @@ -0,0 +1,4 @@ +package stirling.software.SPDF.model; +public enum SortTypes { + REVERSE_ORDER, DUPLEX_SORT, BOOKLET_SORT, SIDE_STITCH_BOOKLET_SORT, ODD_EVEN_SPLIT, REMOVE_FIRST, REMOVE_LAST, REMOVE_FIRST_AND_LAST, +} \ No newline at end of file diff --git a/src/main/java/stirling/software/SPDF/model/api/GeneralFile.java b/src/main/java/stirling/software/SPDF/model/api/GeneralFile.java new file mode 100644 index 00000000..84710585 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/GeneralFile.java @@ -0,0 +1,13 @@ +package stirling.software.SPDF.model.api; + +import org.springframework.web.multipart.MultipartFile; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class GeneralFile { + + @Schema(description = "The input file") + private MultipartFile fileInput; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/ImageFile.java b/src/main/java/stirling/software/SPDF/model/api/ImageFile.java new file mode 100644 index 00000000..8c4c0cff --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/ImageFile.java @@ -0,0 +1,12 @@ +package stirling.software.SPDF.model.api; + +import org.springframework.web.multipart.MultipartFile; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class ImageFile { + @Schema(description = "The input image file") + private MultipartFile fileInput; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/MultiplePDFFiles.java b/src/main/java/stirling/software/SPDF/model/api/MultiplePDFFiles.java new file mode 100644 index 00000000..17bec404 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/MultiplePDFFiles.java @@ -0,0 +1,11 @@ +package stirling.software.SPDF.model.api; + +import org.springframework.web.multipart.MultipartFile; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +@Data +public class MultiplePDFFiles { + @Schema(description = "The input PDF files", type = "array", format = "binary") + private MultipartFile[] fileInput; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/PDFFile.java b/src/main/java/stirling/software/SPDF/model/api/PDFFile.java new file mode 100644 index 00000000..0b304747 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/PDFFile.java @@ -0,0 +1,11 @@ +package stirling.software.SPDF.model.api; + +import org.springframework.web.multipart.MultipartFile; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +@Data +public class PDFFile { + @Schema(description = "The input PDF file") + private MultipartFile fileInput; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/PDFWithPageNums.java b/src/main/java/stirling/software/SPDF/model/api/PDFWithPageNums.java new file mode 100644 index 00000000..4de315de --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/PDFWithPageNums.java @@ -0,0 +1,36 @@ +package stirling.software.SPDF.model.api; + +import java.io.IOException; +import java.util.List; + +import org.apache.pdfbox.pdmodel.PDDocument; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.NoArgsConstructor; +import stirling.software.SPDF.utils.GeneralUtils; +@Data +@NoArgsConstructor +public class PDFWithPageNums extends PDFFile { + + @Schema(description = "The pages to select, Supports ranges (e.g., '1,3,5-9'), or 'all' or functions in the format 'an+b' where 'a' is the multiplier of the page number 'n', and 'b' is a constant (e.g., '2n+1', '3n', '6n-5')\"") + private String pageNumbers; + + + public List getPageNumbersList(){ + int pageCount = 0; + try { + pageCount = PDDocument.load(getFileInput().getInputStream()).getNumberOfPages(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return GeneralUtils.parsePageString(pageNumbers, pageCount); + + } + public List getPageNumbersList(PDDocument doc){ + int pageCount = 0; + pageCount = doc.getNumberOfPages(); + return GeneralUtils.parsePageString(pageNumbers, pageCount); + + } +} diff --git a/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToImageRequest.java b/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToImageRequest.java new file mode 100644 index 00000000..34e36379 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToImageRequest.java @@ -0,0 +1,22 @@ +package stirling.software.SPDF.model.api.converters; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class ConvertToImageRequest extends PDFFile { + + @Schema(description = "The output image format", allowableValues = {"png", "jpeg", "jpg", "gif"}) + private String imageFormat; + + @Schema(description = "Choose between a single image containing all pages or separate images for each page", allowableValues = {"single", "multiple"}) + private String singleOrMultiple; + + @Schema(description = "The color type of the output image(s)", allowableValues = {"color", "greyscale", "blackwhite"}) + private String colorType; + + @Schema(description = "The DPI (dots per inch) for the output image(s)") + private String dpi; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToPdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToPdfRequest.java new file mode 100644 index 00000000..90325ed6 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToPdfRequest.java @@ -0,0 +1,21 @@ +package stirling.software.SPDF.model.api.converters; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +@Data +public class ConvertToPdfRequest { + + @Schema(description = "The input images to be converted to a PDF file") + private MultipartFile[] fileInput; + + @Schema(description = "Whether to stretch the images to fit the PDF page or maintain the aspect ratio", example = "false") + private boolean stretchToFit; + + @Schema(description = "The color type of the output image(s)", allowableValues = {"color", "greyscale", "blackwhite"}) + private String colorType; + + @Schema(description = "Whether to automatically rotate the images to better fit the PDF page", example = "true") + private boolean autoRotate; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/converters/PdfToPresentationRequest.java b/src/main/java/stirling/software/SPDF/model/api/converters/PdfToPresentationRequest.java new file mode 100644 index 00000000..f1bf7a9d --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/converters/PdfToPresentationRequest.java @@ -0,0 +1,13 @@ +package stirling.software.SPDF.model.api.converters; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class PdfToPresentationRequest extends PDFFile { + + @Schema(description = "The output Presentation format", allowableValues = {"ppt", "pptx", "odp"}) + private String outputFormat; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/converters/PdfToTextOrRTFRequest.java b/src/main/java/stirling/software/SPDF/model/api/converters/PdfToTextOrRTFRequest.java new file mode 100644 index 00000000..8093cd45 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/converters/PdfToTextOrRTFRequest.java @@ -0,0 +1,12 @@ +package stirling.software.SPDF.model.api.converters; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class PdfToTextOrRTFRequest extends PDFFile { + + @Schema(description = "The output Text or RTF format", allowableValues = {"rtf", "txt:Text"}) + private String outputFormat; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/converters/PdfToWordRequest.java b/src/main/java/stirling/software/SPDF/model/api/converters/PdfToWordRequest.java new file mode 100644 index 00000000..de5a7c4e --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/converters/PdfToWordRequest.java @@ -0,0 +1,12 @@ +package stirling.software.SPDF.model.api.converters; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class PdfToWordRequest extends PDFFile { + + @Schema(description = "The output Word document format", allowableValues = {"doc", "docx", "odt"}) + private String outputFormat; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/converters/UrlToPdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/converters/UrlToPdfRequest.java new file mode 100644 index 00000000..7d4e69ed --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/converters/UrlToPdfRequest.java @@ -0,0 +1,11 @@ +package stirling.software.SPDF.model.api.converters; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class UrlToPdfRequest { + + @Schema(description = "The input URL to be converted to a PDF file", required = true) + private String urlInput; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/general/CropPdfForm.java b/src/main/java/stirling/software/SPDF/model/api/general/CropPdfForm.java new file mode 100644 index 00000000..52c0f269 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/general/CropPdfForm.java @@ -0,0 +1,26 @@ +package stirling.software.SPDF.model.api.general; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFFile; + +import org.springframework.web.multipart.MultipartFile; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; + +@Data +public class CropPdfForm extends PDFFile { + + + @Schema(description = "The x-coordinate of the top-left corner of the crop area", type = "number") + private float x; + + @Schema(description = "The y-coordinate of the top-left corner of the crop area", type = "number") + private float y; + + @Schema(description = "The width of the crop area", type = "number") + private float width; + + @Schema(description = "The height of the crop area", type = "number") + private float height; +} + diff --git a/src/main/java/stirling/software/SPDF/model/api/general/MergeMultiplePagesRequest.java b/src/main/java/stirling/software/SPDF/model/api/general/MergeMultiplePagesRequest.java new file mode 100644 index 00000000..6752b1b7 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/general/MergeMultiplePagesRequest.java @@ -0,0 +1,13 @@ +package stirling.software.SPDF.model.api.general; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class MergeMultiplePagesRequest extends PDFFile { + + @Schema(description = "The number of pages to fit onto a single sheet in the output PDF.", + type = "integer", allowableValues = {"2", "3", "4", "9", "16"}) + private int pagesPerSheet; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/general/MergePdfsRequest.java b/src/main/java/stirling/software/SPDF/model/api/general/MergePdfsRequest.java new file mode 100644 index 00000000..4e1ed397 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/general/MergePdfsRequest.java @@ -0,0 +1,20 @@ +package stirling.software.SPDF.model.api.general; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.MultiplePDFFiles; + +@Data +public class MergePdfsRequest extends MultiplePDFFiles { + + @Schema(description = "The type of sorting to be applied on the input files before merging.", + allowableValues = { + "orderProvided", + "byFileName", + "byDateModified", + "byDateCreated", + "byPDFTitle" + }, + defaultValue = "orderProvided") + private String sortType; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/general/RearrangePagesRequest.java b/src/main/java/stirling/software/SPDF/model/api/general/RearrangePagesRequest.java new file mode 100644 index 00000000..4e054343 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/general/RearrangePagesRequest.java @@ -0,0 +1,23 @@ +package stirling.software.SPDF.model.api.general; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; +import stirling.software.SPDF.model.api.PDFFile; +import stirling.software.SPDF.model.api.PDFWithPageNums; +import stirling.software.SPDF.model.SortTypes; +@Data +public class RearrangePagesRequest extends PDFWithPageNums { + + @Schema(implementation = SortTypes.class, description = "The custom mode for page rearrangement. Valid values are:\n" + + "REVERSE_ORDER: Reverses the order of all pages.\n" + + "DUPLEX_SORT: Sorts pages as if all fronts were scanned then all backs in reverse (1, n, 2, n-1, ...). " + + "BOOKLET_SORT: Arranges pages for booklet printing (last, first, second, second last, ...).\n" + + "ODD_EVEN_SPLIT: Splits and arranges pages into odd and even numbered pages.\n" + + "REMOVE_FIRST: Removes the first page.\n" + "REMOVE_LAST: Removes the last page.\n" + + "REMOVE_FIRST_AND_LAST: Removes both the first and the last pages.\n") + private String customMode; + + + +} diff --git a/src/main/java/stirling/software/SPDF/model/api/general/RotatePDFRequest.java b/src/main/java/stirling/software/SPDF/model/api/general/RotatePDFRequest.java new file mode 100644 index 00000000..58d268a8 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/general/RotatePDFRequest.java @@ -0,0 +1,13 @@ +package stirling.software.SPDF.model.api.general; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class RotatePDFRequest extends PDFFile { + + @Schema(description = "The angle by which to rotate the PDF file. This should be a multiple of 90.", example = "90") + private Integer angle; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/general/ScalePagesRequest.java b/src/main/java/stirling/software/SPDF/model/api/general/ScalePagesRequest.java new file mode 100644 index 00000000..3411e1d2 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/general/ScalePagesRequest.java @@ -0,0 +1,20 @@ +package stirling.software.SPDF.model.api.general; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class ScalePagesRequest extends PDFFile { + + @Schema(description = "The scale of pages in the output PDF. Acceptable values are A0-A10, B0-B9, LETTER, TABLOID, LEDGER, LEGAL, EXECUTIVE.", + allowableValues = { + "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "B0", "B1", "B2", "B3", "B4", + "B5", "B6", "B7", "B8", "B9", "LETTER", "TABLOID", "LEDGER", "LEGAL", "EXECUTIVE" + }) + private String targetPDRectangle; + + @Schema(description = "The scale of the content on the pages of the output PDF. Acceptable values are floats.") + private float scaleFactor; +} diff --git a/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java b/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java index 34ee9c35..b4377039 100644 --- a/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java +++ b/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java @@ -75,6 +75,9 @@ public class GeneralUtils { return null; } + public static List parsePageString(String pageOrder, int totalPages) { + return parsePageList(pageOrder.split(","), 100); + } public static List parsePageList(String[] pageOrderArr, int totalPages) { List newPageOrder = new ArrayList<>(); From 872f562aadbb8803e24ef73d2a3920ad6749204e Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sat, 9 Sep 2023 18:21:55 +0100 Subject: [PATCH 02/13] misc beginings --- .../api/filters/FilterController.java | 64 +++++++++---------- .../{other => misc}/AutoRenameController.java | 11 ++-- .../AutoSplitPdfController.java | 11 ++-- .../{other => misc}/BlankPageController.java | 18 ++---- .../{other => misc}/CompressController.java | 15 +++-- .../ExtractImageScansController.java | 7 +- .../ExtractImagesController.java | 2 +- .../FakeScanControllerWIP.java | 2 +- .../{other => misc}/MetadataController.java | 2 +- .../api/{other => misc}/OCRController.java | 2 +- .../OverlayImageController.java | 2 +- .../PageNumbersController.java | 2 +- .../api/{other => misc}/RepairController.java | 2 +- .../api/{other => misc}/ShowJavascript.java | 2 +- .../SPDF/model/api/PDFComparison.java | 19 ++++++ .../SPDF/model/api/PDFComparisonAndCount.java | 18 ++++++ .../model/api/filter/ContainsTextRequest.java | 12 ++++ .../model/api/filter/FileSizeRequest.java | 15 +++++ .../model/api/filter/PageRotationRequest.java | 14 ++++ .../model/api/filter/PageSizeRequest.java | 15 +++++ .../model/api/misc/AutoSplitPdfRequest.java | 12 ++++ .../model/api/misc/ExtractHeaderRequest.java | 12 ++++ .../api/misc/ExtractImageScansRequest.java} | 4 +- .../model/api/misc/OptimizePdfRequest.java | 16 +++++ .../api/misc/RemoveBlankPagesRequest.java | 15 +++++ 25 files changed, 221 insertions(+), 73 deletions(-) rename src/main/java/stirling/software/SPDF/controller/api/{other => misc}/AutoRenameController.java (90%) rename src/main/java/stirling/software/SPDF/controller/api/{other => misc}/AutoSplitPdfController.java (91%) rename src/main/java/stirling/software/SPDF/controller/api/{other => misc}/BlankPageController.java (87%) rename src/main/java/stirling/software/SPDF/controller/api/{other => misc}/CompressController.java (93%) rename src/main/java/stirling/software/SPDF/controller/api/{other => misc}/ExtractImageScansController.java (95%) rename src/main/java/stirling/software/SPDF/controller/api/{other => misc}/ExtractImagesController.java (98%) rename src/main/java/stirling/software/SPDF/controller/api/{other => misc}/FakeScanControllerWIP.java (99%) rename src/main/java/stirling/software/SPDF/controller/api/{other => misc}/MetadataController.java (99%) rename src/main/java/stirling/software/SPDF/controller/api/{other => misc}/OCRController.java (99%) rename src/main/java/stirling/software/SPDF/controller/api/{other => misc}/OverlayImageController.java (98%) rename src/main/java/stirling/software/SPDF/controller/api/{other => misc}/PageNumbersController.java (96%) rename src/main/java/stirling/software/SPDF/controller/api/{other => misc}/RepairController.java (98%) rename src/main/java/stirling/software/SPDF/controller/api/{other => misc}/ShowJavascript.java (97%) create mode 100644 src/main/java/stirling/software/SPDF/model/api/PDFComparison.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/PDFComparisonAndCount.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/filter/ContainsTextRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/filter/FileSizeRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/filter/PageRotationRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/filter/PageSizeRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/misc/AutoSplitPdfRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/misc/ExtractHeaderRequest.java rename src/main/java/stirling/software/SPDF/{controller/api/other/MyForm.java => model/api/misc/ExtractImageScansRequest.java} (91%) create mode 100644 src/main/java/stirling/software/SPDF/model/api/misc/OptimizePdfRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/misc/RemoveBlankPagesRequest.java diff --git a/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java b/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java index bd2e75be..dbb20bfe 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java @@ -6,6 +6,7 @@ import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.common.PDRectangle; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -15,6 +16,12 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.PDFComparisonAndCount; +import stirling.software.SPDF.model.api.PDFWithPageNums; +import stirling.software.SPDF.model.api.filter.ContainsTextRequest; +import stirling.software.SPDF.model.api.filter.FileSizeRequest; +import stirling.software.SPDF.model.api.filter.PageRotationRequest; +import stirling.software.SPDF.model.api.filter.PageSizeRequest; import stirling.software.SPDF.utils.PdfUtils; import stirling.software.SPDF.utils.WebResponseUtils; @@ -24,11 +31,11 @@ public class FilterController { @PostMapping(consumes = "multipart/form-data", value = "/filter-contains-text") @Operation(summary = "Checks if a PDF contains set text, returns true if does", description = "Input:PDF Output:Boolean Type:SISO") - public ResponseEntity containsText( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file to be converted to a PDF/A file", required = true) MultipartFile inputFile, - @Parameter(description = "The text to check for", required = true) String text, - @Parameter(description = "The page number to check for text on accepts 'All', ranges like '1-4'", required = false) String pageNumber) - throws IOException, InterruptedException { + public ResponseEntity containsText(@ModelAttribute ContainsTextRequest request) throws IOException, InterruptedException { + MultipartFile inputFile = request.getFileInput(); + String text = request.getText(); + String pageNumber = request.getPageNumbers(); + PDDocument pdfDocument = PDDocument.load(inputFile.getInputStream()); if (PdfUtils.hasText(pdfDocument, pageNumber, text)) return WebResponseUtils.pdfDocToWebResponse(pdfDocument, inputFile.getOriginalFilename()); @@ -38,10 +45,11 @@ public class FilterController { // TODO @PostMapping(consumes = "multipart/form-data", value = "/filter-contains-image") @Operation(summary = "Checks if a PDF contains an image", description = "Input:PDF Output:Boolean Type:SISO") - public ResponseEntity containsImage( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file to be converted to a PDF/A file", required = true) MultipartFile inputFile, - @Parameter(description = "The page number to check for image on accepts 'All', ranges like '1-4'", required = false) String pageNumber) + public ResponseEntity containsImage(@ModelAttribute PDFWithPageNums request) throws IOException, InterruptedException { + MultipartFile inputFile = request.getFileInput(); + String pageNumber = request.getPageNumbers(); + PDDocument pdfDocument = PDDocument.load(inputFile.getInputStream()); if (PdfUtils.hasImages(pdfDocument, pageNumber)) return WebResponseUtils.pdfDocToWebResponse(pdfDocument, inputFile.getOriginalFilename()); @@ -50,12 +58,10 @@ public class FilterController { @PostMapping(consumes = "multipart/form-data", value = "/filter-page-count") @Operation(summary = "Checks if a PDF is greater, less or equal to a setPageCount", description = "Input:PDF Output:Boolean Type:SISO") - public ResponseEntity pageCount( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file", required = true) MultipartFile inputFile, - @Parameter(description = "Page Count", required = true) String pageCount, - @Parameter(description = "Comparison type", schema = @Schema(description = "The comparison type, accepts Greater, Equal, Less than", allowableValues = { - "Greater", "Equal", "Less" })) String comparator) - throws IOException, InterruptedException { + public ResponseEntity pageCount(@ModelAttribute PDFComparisonAndCount request) throws IOException, InterruptedException { + MultipartFile inputFile = request.getFileInput(); + String pageCount = request.getPageCount(); + String comparator = request.getComparator(); // Load the PDF PDDocument document = PDDocument.load(inputFile.getInputStream()); int actualPageCount = document.getNumberOfPages(); @@ -83,12 +89,10 @@ public class FilterController { @PostMapping(consumes = "multipart/form-data", value = "/filter-page-size") @Operation(summary = "Checks if a PDF is of a certain size", description = "Input:PDF Output:Boolean Type:SISO") - public ResponseEntity pageSize( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file", required = true) MultipartFile inputFile, - @Parameter(description = "Standard Page Size", required = true) String standardPageSize, - @Parameter(description = "Comparison type", schema = @Schema(description = "The comparison type, accepts Greater, Equal, Less than", allowableValues = { - "Greater", "Equal", "Less" })) String comparator) - throws IOException, InterruptedException { + public ResponseEntity pageSize(@ModelAttribute PageSizeRequest request) throws IOException, InterruptedException { + MultipartFile inputFile = request.getFileInput(); + String standardPageSize = request.getStandardPageSize(); + String comparator = request.getComparator(); // Load the PDF PDDocument document = PDDocument.load(inputFile.getInputStream()); @@ -126,12 +130,10 @@ public class FilterController { @PostMapping(consumes = "multipart/form-data", value = "/filter-file-size") @Operation(summary = "Checks if a PDF is a set file size", description = "Input:PDF Output:Boolean Type:SISO") - public ResponseEntity fileSize( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file", required = true) MultipartFile inputFile, - @Parameter(description = "File Size", required = true) String fileSize, - @Parameter(description = "Comparison type", schema = @Schema(description = "The comparison type, accepts Greater, Equal, Less than", allowableValues = { - "Greater", "Equal", "Less" })) String comparator) - throws IOException, InterruptedException { + public ResponseEntity fileSize(@ModelAttribute FileSizeRequest request) throws IOException, InterruptedException { + MultipartFile inputFile = request.getFileInput(); + String fileSize = request.getFileSize(); + String comparator = request.getComparator(); // Get the file size long actualFileSize = inputFile.getSize(); @@ -159,12 +161,10 @@ public class FilterController { @PostMapping(consumes = "multipart/form-data", value = "/filter-page-rotation") @Operation(summary = "Checks if a PDF is of a certain rotation", description = "Input:PDF Output:Boolean Type:SISO") - public ResponseEntity pageRotation( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file", required = true) MultipartFile inputFile, - @Parameter(description = "Rotation in degrees", required = true) int rotation, - @Parameter(description = "Comparison type", schema = @Schema(description = "The comparison type, accepts Greater, Equal, Less than", allowableValues = { - "Greater", "Equal", "Less" })) String comparator) - throws IOException, InterruptedException { + public ResponseEntity pageRotation(@ModelAttribute PageRotationRequest request) throws IOException, InterruptedException { + MultipartFile inputFile = request.getFileInput(); + int rotation = request.getRotation(); + String comparator = request.getComparator(); // Load the PDF PDDocument document = PDDocument.load(inputFile.getInputStream()); diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/AutoRenameController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java similarity index 90% rename from src/main/java/stirling/software/SPDF/controller/api/other/AutoRenameController.java rename to src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java index eb20f3bd..8059062c 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/AutoRenameController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api.misc; import java.io.IOException; import java.util.ArrayList; @@ -11,6 +11,7 @@ import org.apache.pdfbox.text.TextPosition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -20,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.misc.ExtractHeaderRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @Tag(name = "Other", description = "Other APIs") @@ -32,10 +34,9 @@ public class AutoRenameController { @PostMapping(consumes = "multipart/form-data", value = "/auto-rename") @Operation(summary = "Extract header from PDF file", description = "This endpoint accepts a PDF file and attempts to extract its title or header based on heuristics. Input:PDF Output:PDF Type:SISO") - public ResponseEntity extractHeader( - @RequestPart(value = "fileInput") @Parameter(description = "The input PDF file from which the header is to be extracted.", required = true) MultipartFile file, - @RequestParam(required = false, defaultValue = "false") @Parameter(description = "Flag indicating whether to use the first text as a fallback if no suitable title is found. Defaults to false.", required = false) Boolean useFirstTextAsFallback) - throws Exception { + public ResponseEntity extractHeader(@ModelAttribute ExtractHeaderRequest request) throws Exception { + MultipartFile file = request.getFileInput(); + Boolean useFirstTextAsFallback = request.getUseFirstTextAsFallback(); PDDocument document = PDDocument.load(file.getInputStream()); PDFTextStripper reader = new PDFTextStripper() { diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/AutoSplitPdfController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java similarity index 91% rename from src/main/java/stirling/software/SPDF/controller/api/other/AutoSplitPdfController.java rename to src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java index e3e56847..3ba81f78 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/AutoSplitPdfController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api.misc; import java.awt.image.BufferedImage; import java.awt.image.DataBufferByte; import java.awt.image.DataBufferInt; @@ -16,6 +16,7 @@ import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.rendering.PDFRenderer; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -31,6 +32,7 @@ import com.google.zxing.common.HybridBinarizer; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import stirling.software.SPDF.model.api.misc.AutoSplitPdfRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @@ -40,10 +42,9 @@ public class AutoSplitPdfController { @PostMapping(value = "/auto-split-pdf", consumes = "multipart/form-data") @Operation(summary = "Auto split PDF pages into separate documents", description = "This endpoint accepts a PDF file, scans each page for a specific QR code, and splits the document at the QR code boundaries. The output is a zip file containing each separate PDF document. Input:PDF Output:ZIP Type:SISO") - public ResponseEntity autoSplitPdf( - @RequestParam("fileInput") @Parameter(description = "The input PDF file which needs to be split into separate documents based on QR code boundaries.", required = true) MultipartFile file, - @RequestParam(value ="duplexMode",defaultValue = "false") @Parameter(description = "Flag indicating if the duplex mode is active, where the page after the divider also gets removed.", required = false) boolean duplexMode) - throws IOException { + public ResponseEntity autoSplitPdf(@ModelAttribute AutoSplitPdfRequest request) throws IOException { + MultipartFile file = request.getFileInput(); + boolean duplexMode = request.isDuplexMode(); InputStream inputStream = file.getInputStream(); PDDocument document = PDDocument.load(inputStream); diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/BlankPageController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java similarity index 87% rename from src/main/java/stirling/software/SPDF/controller/api/other/BlankPageController.java rename to src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java index 4f505b73..5107d8c0 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/BlankPageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api.misc; import java.awt.image.BufferedImage; import java.io.IOException; @@ -20,6 +20,7 @@ import org.apache.pdfbox.rendering.PDFRenderer; import org.apache.pdfbox.text.PDFTextStripper; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -29,6 +30,7 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.misc.RemoveBlankPagesRequest; import stirling.software.SPDF.utils.PdfUtils; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; @@ -43,16 +45,10 @@ public class BlankPageController { summary = "Remove blank pages from a PDF file", description = "This endpoint removes blank pages from a given PDF file. Users can specify the threshold and white percentage to tune the detection of blank pages. Input:PDF Output:PDF Type:SISO" ) - public ResponseEntity removeBlankPages( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file from which blank pages will be removed", required = true) - MultipartFile inputFile, - @RequestParam(defaultValue = "10", name = "threshold") - @Parameter(description = "The threshold value to determine blank pages", example = "10") - int threshold, - @RequestParam(defaultValue = "99.9", name = "whitePercent") - @Parameter(description = "The percentage of white color on a page to consider it as blank", example = "99.9") - float whitePercent) throws IOException, InterruptedException { + public ResponseEntity removeBlankPages(@ModelAttribute RemoveBlankPagesRequest request) throws IOException, InterruptedException { + MultipartFile inputFile = request.getFileInput(); + int threshold = request.getThreshold(); + float whitePercent = request.getWhitePercent(); PDDocument document = null; try { diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/CompressController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java similarity index 93% rename from src/main/java/stirling/software/SPDF/controller/api/other/CompressController.java rename to src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java index 381a6821..89147056 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/CompressController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api.misc; import java.awt.Image; import java.awt.image.BufferedImage; @@ -22,6 +22,7 @@ import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -32,6 +33,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.misc.OptimizePdfRequest; import stirling.software.SPDF.utils.GeneralUtils; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; @@ -45,12 +47,11 @@ public class CompressController { @PostMapping(consumes = "multipart/form-data", value = "/compress-pdf") @Operation(summary = "Optimize PDF file", description = "This endpoint accepts a PDF file and optimizes it based on the provided parameters. Input:PDF Output:PDF Type:SISO") - public ResponseEntity optimizePdf( - @RequestPart(value = "fileInput") @Parameter(description = "The input PDF file to be optimized.", required = true) MultipartFile inputFile, - @RequestParam(required = false, value = "optimizeLevel") @Parameter(description = "The level of optimization to apply to the PDF file. Higher values indicate greater compression but may reduce quality.", schema = @Schema(allowableValues = { - "1", "2", "3", "4", "5" })) Integer optimizeLevel, - @RequestParam(value = "expectedOutputSize", required = false) @Parameter(description = "The expected output size, e.g. '100MB', '25KB', etc.", required = false) String expectedOutputSizeString) - throws Exception { + public ResponseEntity optimizePdf(@ModelAttribute OptimizePdfRequest request) throws Exception { + MultipartFile inputFile = request.getFileInput(); + Integer optimizeLevel = request.getOptimizeLevel(); + String expectedOutputSizeString = request.getExpectedOutputSizeString(); + if(expectedOutputSizeString == null && optimizeLevel == null) { throw new Exception("Both expected output size and optimize level are not specified"); diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImageScansController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java similarity index 95% rename from src/main/java/stirling/software/SPDF/controller/api/other/ExtractImageScansController.java rename to src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java index cb13682d..5a1bbf8a 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImageScansController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api.misc; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; @@ -33,6 +33,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.misc.ExtractImageScansRequest; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; @@ -53,10 +54,10 @@ public class ExtractImageScansController { required = true, content = @Content( mediaType = "multipart/form-data", - schema = @Schema(implementation = MyForm.class) // This should represent your form's structure + schema = @Schema(implementation = ExtractImageScansRequest.class) // This should represent your form's structure ) ) - MyForm form) throws IOException, InterruptedException { + ExtractImageScansRequest form) throws IOException, InterruptedException { String fileName = form.getFileInput().getOriginalFilename(); String extension = fileName.substring(fileName.lastIndexOf(".") + 1); diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImagesController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImagesController.java similarity index 98% rename from src/main/java/stirling/software/SPDF/controller/api/other/ExtractImagesController.java rename to src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImagesController.java index c10dd7b4..206c78a2 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImagesController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImagesController.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api.misc; import java.awt.Graphics2D; import java.awt.Image; diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/FakeScanControllerWIP.java b/src/main/java/stirling/software/SPDF/controller/api/misc/FakeScanControllerWIP.java similarity index 99% rename from src/main/java/stirling/software/SPDF/controller/api/other/FakeScanControllerWIP.java rename to src/main/java/stirling/software/SPDF/controller/api/misc/FakeScanControllerWIP.java index 19c5aa5e..e3ec8d5e 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/FakeScanControllerWIP.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/FakeScanControllerWIP.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api.misc; import java.awt.Color; import java.awt.geom.AffineTransform; diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/MetadataController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java similarity index 99% rename from src/main/java/stirling/software/SPDF/controller/api/other/MetadataController.java rename to src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java index e3979d10..059db19d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/MetadataController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api.misc; import java.io.IOException; import java.text.ParseException; diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/OCRController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java similarity index 99% rename from src/main/java/stirling/software/SPDF/controller/api/other/OCRController.java rename to src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java index d6009c8a..768493ab 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/OCRController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api.misc; import java.io.File; import java.io.FileOutputStream; diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/OverlayImageController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java similarity index 98% rename from src/main/java/stirling/software/SPDF/controller/api/other/OverlayImageController.java rename to src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java index 61768f6a..975e7628 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/OverlayImageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api.misc; import java.io.IOException; diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/PageNumbersController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java similarity index 96% rename from src/main/java/stirling/software/SPDF/controller/api/other/PageNumbersController.java rename to src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java index 8e38bd10..2192d876 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/PageNumbersController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api.misc; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/RepairController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java similarity index 98% rename from src/main/java/stirling/software/SPDF/controller/api/other/RepairController.java rename to src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java index 52644080..e9983902 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/RepairController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api.misc; import java.io.IOException; import java.nio.file.Files; diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/ShowJavascript.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java similarity index 97% rename from src/main/java/stirling/software/SPDF/controller/api/other/ShowJavascript.java rename to src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java index d812f5c8..08ac3e1b 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/ShowJavascript.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.controller.api.misc; import java.nio.charset.StandardCharsets; import java.util.Map; diff --git a/src/main/java/stirling/software/SPDF/model/api/PDFComparison.java b/src/main/java/stirling/software/SPDF/model/api/PDFComparison.java new file mode 100644 index 00000000..5d7871b0 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/PDFComparison.java @@ -0,0 +1,19 @@ +package stirling.software.SPDF.model.api; + +import java.io.IOException; +import java.util.List; + +import org.apache.pdfbox.pdmodel.PDDocument; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.NoArgsConstructor; +import stirling.software.SPDF.utils.GeneralUtils; +@Data +@NoArgsConstructor +public class PDFComparison extends PDFFile { + + @Schema(description = "The comparison type, accepts Greater, Equal, Less than", allowableValues = { + "Greater", "Equal", "Less" }) + private String comparator; + +} diff --git a/src/main/java/stirling/software/SPDF/model/api/PDFComparisonAndCount.java b/src/main/java/stirling/software/SPDF/model/api/PDFComparisonAndCount.java new file mode 100644 index 00000000..8779ba57 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/PDFComparisonAndCount.java @@ -0,0 +1,18 @@ +package stirling.software.SPDF.model.api; + +import java.io.IOException; +import java.util.List; + +import org.apache.pdfbox.pdmodel.PDDocument; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.NoArgsConstructor; +import stirling.software.SPDF.utils.GeneralUtils; +@Data +@NoArgsConstructor +public class PDFComparisonAndCount extends PDFComparison { + @Schema(description = "Count") + private String pageCount; + + +} diff --git a/src/main/java/stirling/software/SPDF/model/api/filter/ContainsTextRequest.java b/src/main/java/stirling/software/SPDF/model/api/filter/ContainsTextRequest.java new file mode 100644 index 00000000..4dc4e137 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/filter/ContainsTextRequest.java @@ -0,0 +1,12 @@ +package stirling.software.SPDF.model.api.filter; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFWithPageNums; + +@Data +public class ContainsTextRequest extends PDFWithPageNums { + + @Schema(description = "The text to check for", required = true) + private String text; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/filter/FileSizeRequest.java b/src/main/java/stirling/software/SPDF/model/api/filter/FileSizeRequest.java new file mode 100644 index 00000000..cffcd9a4 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/filter/FileSizeRequest.java @@ -0,0 +1,15 @@ +package stirling.software.SPDF.model.api.filter; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFComparison; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class FileSizeRequest extends PDFComparison { + + @Schema(description = "File Size", required = true) + private String fileSize; + + +} diff --git a/src/main/java/stirling/software/SPDF/model/api/filter/PageRotationRequest.java b/src/main/java/stirling/software/SPDF/model/api/filter/PageRotationRequest.java new file mode 100644 index 00000000..8f36ae5d --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/filter/PageRotationRequest.java @@ -0,0 +1,14 @@ +package stirling.software.SPDF.model.api.filter; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFComparison; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class PageRotationRequest extends PDFComparison { + + @Schema(description = "Rotation in degrees", required = true) + private int rotation; + +} diff --git a/src/main/java/stirling/software/SPDF/model/api/filter/PageSizeRequest.java b/src/main/java/stirling/software/SPDF/model/api/filter/PageSizeRequest.java new file mode 100644 index 00000000..0184ac90 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/filter/PageSizeRequest.java @@ -0,0 +1,15 @@ +package stirling.software.SPDF.model.api.filter; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFComparison; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class PageSizeRequest extends PDFComparison { + + @Schema(description = "Standard Page Size", required = true) + private String standardPageSize; + + +} diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/AutoSplitPdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/AutoSplitPdfRequest.java new file mode 100644 index 00000000..822eb7a6 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/misc/AutoSplitPdfRequest.java @@ -0,0 +1,12 @@ +package stirling.software.SPDF.model.api.misc; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class AutoSplitPdfRequest extends PDFFile { + + @Schema(description = "Flag indicating if the duplex mode is active, where the page after the divider also gets removed.", required = false, defaultValue = "false") + private boolean duplexMode; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/ExtractHeaderRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/ExtractHeaderRequest.java new file mode 100644 index 00000000..d05b865e --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/misc/ExtractHeaderRequest.java @@ -0,0 +1,12 @@ +package stirling.software.SPDF.model.api.misc; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class ExtractHeaderRequest extends PDFFile { + + @Schema(description = "Flag indicating whether to use the first text as a fallback if no suitable title is found. Defaults to false.", required = false, defaultValue = "false") + private Boolean useFirstTextAsFallback; +} diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/MyForm.java b/src/main/java/stirling/software/SPDF/model/api/misc/ExtractImageScansRequest.java similarity index 91% rename from src/main/java/stirling/software/SPDF/controller/api/other/MyForm.java rename to src/main/java/stirling/software/SPDF/model/api/misc/ExtractImageScansRequest.java index 1938493a..8a12fc47 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/MyForm.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/ExtractImageScansRequest.java @@ -1,4 +1,4 @@ -package stirling.software.SPDF.controller.api.other; +package stirling.software.SPDF.model.api.misc; import org.springframework.web.multipart.MultipartFile; @@ -6,7 +6,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @Data -public class MyForm { +public class ExtractImageScansRequest { @Schema(description = "The input file containing image scans", required = true) private MultipartFile fileInput; diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/OptimizePdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/OptimizePdfRequest.java new file mode 100644 index 00000000..65028a7f --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/misc/OptimizePdfRequest.java @@ -0,0 +1,16 @@ +package stirling.software.SPDF.model.api.misc; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class OptimizePdfRequest extends PDFFile { + + @Schema(description = "The level of optimization to apply to the PDF file. Higher values indicate greater compression but may reduce quality.", + allowableValues = { "1", "2", "3", "4", "5" }) + private Integer optimizeLevel; + + @Schema(description = "The expected output size, e.g. '100MB', '25KB', etc.") + private String expectedOutputSizeString; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/RemoveBlankPagesRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/RemoveBlankPagesRequest.java new file mode 100644 index 00000000..a7a92897 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/misc/RemoveBlankPagesRequest.java @@ -0,0 +1,15 @@ +package stirling.software.SPDF.model.api.misc; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class RemoveBlankPagesRequest extends PDFFile { + + @Schema(description = "The threshold value to determine blank pages", example = "10", defaultValue = "10") + private int threshold; + + @Schema(description = "The percentage of white color on a page to consider it as blank", example = "99.9", defaultValue = "99.9") + private float whitePercent; +} From 145e8006f0773f884e67d45928b0b9b91622c0a6 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sat, 9 Sep 2023 18:51:43 +0100 Subject: [PATCH 03/13] metadata --- .../api/misc/ExtractImagesController.java | 12 ++-- .../api/misc/FakeScanControllerWIP.java | 8 +-- .../api/misc/MetadataController.java | 58 +++++++------------ .../model/api/PDFWithImageFormatRequest.java | 12 ++++ .../SPDF/model/api/misc/MetadataRequest.java | 44 ++++++++++++++ 5 files changed, 86 insertions(+), 48 deletions(-) create mode 100644 src/main/java/stirling/software/SPDF/model/api/PDFWithImageFormatRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/misc/MetadataRequest.java 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 206c78a2..91bbff09 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 @@ -20,6 +20,7 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -30,6 +31,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.PDFWithImageFormatRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @Tag(name = "Other", description = "Other APIs") @@ -40,13 +42,9 @@ public class ExtractImagesController { @PostMapping(consumes = "multipart/form-data", value = "/extract-images") @Operation(summary = "Extract images from a PDF file", description = "This endpoint extracts images from a given PDF file and returns them in a zip file. Users can specify the output image format. Input:PDF Output:IMAGE/ZIP Type:SIMO") - public ResponseEntity extractImages( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file containing images") - MultipartFile file, - @RequestParam("format") - @Parameter(description = "The output image format e.g., 'png', 'jpeg', or 'gif'", schema = @Schema(allowableValues = {"png", "jpeg", "gif"})) - String format) throws IOException { + public ResponseEntity extractImages(@ModelAttribute PDFWithImageFormatRequest request) throws IOException { + MultipartFile file = request.getFileInput(); + String format = request.getFormat(); System.out.println(System.currentTimeMillis() + "file=" + file.getName() + ", format=" + format); PDDocument document = PDDocument.load(file.getBytes()); 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 e3ec8d5e..70fc2e88 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 @@ -30,6 +30,7 @@ import org.apache.pdfbox.rendering.PDFRenderer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -39,6 +40,7 @@ import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @@ -54,10 +56,8 @@ public class FakeScanControllerWIP { summary = "Repair a PDF file", description = "This endpoint repairs a given PDF file by running Ghostscript command. The PDF is first saved to a temporary location, repaired, read back, and then returned as a response." ) - public ResponseEntity repairPdf( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file to be repaired", required = true) - MultipartFile inputFile) throws IOException, InterruptedException { + public ResponseEntity repairPdf(@ModelAttribute PDFFile request) throws IOException { + MultipartFile inputFile = request.getFileInput(); PDDocument document = PDDocument.load(inputFile.getBytes()); PDFRenderer pdfRenderer = new PDFRenderer(document); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java index 059db19d..aa9b5395 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java @@ -11,6 +11,7 @@ import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDDocumentInformation; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -20,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.misc.MetadataRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @@ -41,43 +43,25 @@ public class MetadataController { @PostMapping(consumes = "multipart/form-data", value = "/update-metadata") @Operation(summary = "Update metadata of a PDF file", description = "This endpoint allows you to update the metadata of a given PDF file. You can add, modify, or delete standard and custom metadata fields. Input:PDF Output:PDF Type:SISO") - public ResponseEntity metadata( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file to update metadata") - MultipartFile pdfFile, - @RequestParam(value = "deleteAll", required = false, defaultValue = "false") - @Parameter(description = "Delete all metadata if set to true") - Boolean deleteAll, - @RequestParam(value = "author", required = false) - @Parameter(description = "The author of the document") - String author, - @RequestParam(value = "creationDate", required = false) - @Parameter(description = "The creation date of the document (format: yyyy/MM/dd HH:mm:ss)") - String creationDate, - @RequestParam(value = "creator", required = false) - @Parameter(description = "The creator of the document") - String creator, - @RequestParam(value = "keywords", required = false) - @Parameter(description = "The keywords for the document") - String keywords, - @RequestParam(value = "modificationDate", required = false) - @Parameter(description = "The modification date of the document (format: yyyy/MM/dd HH:mm:ss)") - String modificationDate, - @RequestParam(value = "producer", required = false) - @Parameter(description = "The producer of the document") - String producer, - @RequestParam(value = "subject", required = false) - @Parameter(description = "The subject of the document") - String subject, - @RequestParam(value = "title", required = false) - @Parameter(description = "The title of the document") - String title, - @RequestParam(value = "trapped", required = false) - @Parameter(description = "The trapped status of the document") - String trapped, - @Parameter(description = "Map list of key and value of custom parameters, note these must start with customKey and customValue if they are non standard") - @RequestParam Map allRequestParams) - throws IOException { + public ResponseEntity metadata(@ModelAttribute MetadataRequest request) throws IOException { + + // Extract PDF file from the request object + MultipartFile pdfFile = request.getFileInput(); + + // Extract metadata information + Boolean deleteAll = request.getDeleteAll(); + String author = request.getAuthor(); + String creationDate = request.getCreationDate(); + String creator = request.getCreator(); + String keywords = request.getKeywords(); + String modificationDate = request.getModificationDate(); + String producer = request.getProducer(); + String subject = request.getSubject(); + String title = request.getTitle(); + String trapped = request.getTrapped(); + + // Extract additional custom parameters + Map allRequestParams = request.getAllRequestParams(); // Load the PDF file into a PDDocument PDDocument document = PDDocument.load(pdfFile.getBytes()); diff --git a/src/main/java/stirling/software/SPDF/model/api/PDFWithImageFormatRequest.java b/src/main/java/stirling/software/SPDF/model/api/PDFWithImageFormatRequest.java new file mode 100644 index 00000000..9766fdbf --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/PDFWithImageFormatRequest.java @@ -0,0 +1,12 @@ +package stirling.software.SPDF.model.api; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class PDFWithImageFormatRequest extends PDFFile { + + @Schema(description = "The output image format e.g., 'png', 'jpeg', or 'gif'", + allowableValues = { "png", "jpeg", "gif" }) + private String format; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/MetadataRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/MetadataRequest.java new file mode 100644 index 00000000..586f83f5 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/misc/MetadataRequest.java @@ -0,0 +1,44 @@ +package stirling.software.SPDF.model.api.misc; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFFile; + +import java.util.Map; + +@Data +public class MetadataRequest extends PDFFile { + + @Schema(description = "Delete all metadata if set to true") + private Boolean deleteAll; + + @Schema(description = "The author of the document") + private String author; + + @Schema(description = "The creation date of the document (format: yyyy/MM/dd HH:mm:ss)") + private String creationDate; + + @Schema(description = "The creator of the document") + private String creator; + + @Schema(description = "The keywords for the document") + private String keywords; + + @Schema(description = "The modification date of the document (format: yyyy/MM/dd HH:mm:ss)") + private String modificationDate; + + @Schema(description = "The producer of the document") + private String producer; + + @Schema(description = "The subject of the document") + private String subject; + + @Schema(description = "The title of the document") + private String title; + + @Schema(description = "The trapped status of the document") + private String trapped; + + @Schema(description = "Map list of key and value of custom parameters. Note these must start with customKey and customValue if they are non-standard") + private Map allRequestParams; +} From 1f4aae9249413ee2d3f5b288c75b146a10f7a1ff Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sun, 10 Sep 2023 01:10:24 +0100 Subject: [PATCH 04/13] finishing forms --- .../controller/api/misc/OCRController.java | 41 ++++-------- .../api/misc/OverlayImageController.java | 24 +++---- .../api/misc/PageNumbersController.java | 17 ++--- .../controller/api/misc/RepairController.java | 10 +-- .../controller/api/misc/ShowJavascript.java | 7 +- .../api/pipeline/PipelineController.java | 7 +- .../api/security/CertSignController.java | 38 ++++------- .../controller/api/security/GetInfoOnPDF.java | 8 +-- .../api/security/PasswordController.java | 67 ++++++------------- .../api/security/RedactController.java | 18 ++--- .../api/security/SanitizeController.java | 28 +++----- .../api/security/WatermarkController.java | 29 ++++---- .../SPDF/model/api/HandleDataRequest.java | 15 +++++ .../model/api/misc/AddPageNumbersRequest.java | 26 +++++++ .../model/api/misc/OverlayImageRequest.java | 23 +++++++ .../api/misc/ProcessPdfWithOcrRequest.java | 36 ++++++++++ .../api/security/AddPasswordRequest.java | 43 ++++++++++++ .../api/security/AddWatermarkRequest.java | 39 +++++++++++ .../api/security/PDFPasswordRequest.java | 13 ++++ .../model/api/security/RedactPdfRequest.java | 28 ++++++++ .../api/security/SanitizePdfRequest.java | 25 +++++++ .../api/security/SignPDFWithCertRequest.java | 40 +++++++++++ 22 files changed, 403 insertions(+), 179 deletions(-) create mode 100644 src/main/java/stirling/software/SPDF/model/api/HandleDataRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/misc/AddPageNumbersRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/misc/OverlayImageRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/security/AddPasswordRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/security/AddWatermarkRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/security/PDFPasswordRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/security/RedactPdfRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/security/SanitizePdfRequest.java create mode 100644 src/main/java/stirling/software/SPDF/model/api/security/SignPDFWithCertRequest.java diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java index 768493ab..aa25b9b4 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java @@ -18,6 +18,7 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -28,6 +29,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.misc.ProcessPdfWithOcrRequest; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; @@ -51,35 +53,16 @@ public class OCRController { @PostMapping(consumes = "multipart/form-data", value = "/ocr-pdf") @Operation(summary = "Process a PDF file with OCR", description = "This endpoint processes a PDF file using OCR (Optical Character Recognition). Users can specify languages, sidecar, deskew, clean, cleanFinal, ocrType, ocrRenderType, and removeImagesAfter options. Input:PDF Output:PDF Type:SI-Conditional") - public ResponseEntity processPdfWithOCR( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file to be processed with OCR") - MultipartFile inputFile, - @RequestParam("languages") - @Parameter(description = "List of languages to use in OCR processing") - List selectedLanguages, - @RequestParam(name = "sidecar", required = false) - @Parameter(description = "Include OCR text in a sidecar text file if set to true") - Boolean sidecar, - @RequestParam(name = "deskew", required = false) - @Parameter(description = "Deskew the input file if set to true") - Boolean deskew, - @RequestParam(name = "clean", required = false) - @Parameter(description = "Clean the input file if set to true") - Boolean clean, - @RequestParam(name = "clean-final", required = false) - @Parameter(description = "Clean the final output if set to true") - Boolean cleanFinal, - @RequestParam(name = "ocrType", required = false) - @Parameter(description = "Specify the OCR type, e.g., 'skip-text', 'force-ocr', or 'Normal'", schema = @Schema(allowableValues = {"skip-text", "force-ocr", "Normal"})) - String ocrType, - @RequestParam(name = "ocrRenderType", required = false, defaultValue = "hocr") - @Parameter(description = "Specify the OCR render type, either 'hocr' or 'sandwich'", schema = @Schema(allowableValues = {"hocr", "sandwich"})) - String ocrRenderType, - @RequestParam(name = "removeImagesAfter", required = false) - @Parameter(description = "Remove images from the output PDF if set to true") - Boolean removeImagesAfter) throws IOException, InterruptedException { - + public ResponseEntity processPdfWithOCR(@ModelAttribute ProcessPdfWithOcrRequest request) throws IOException, InterruptedException { + MultipartFile inputFile = request.getFileInput(); + List selectedLanguages = request.getSelectedLanguages(); + Boolean sidecar = request.getSidecar(); + Boolean deskew = request.getDeskew(); + Boolean clean = request.getClean(); + Boolean cleanFinal = request.getCleanFinal(); + String ocrType = request.getOcrType(); + String ocrRenderType = request.getOcrRenderType(); + Boolean removeImagesAfter = request.getRemoveImagesAfter(); // --output-type pdfa if (selectedLanguages == null || selectedLanguages.isEmpty()) { throw new IOException("Please select at least one language."); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java index 975e7628..44c16fd7 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java @@ -6,6 +6,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -15,6 +16,7 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.misc.OverlayImageRequest; import stirling.software.SPDF.utils.PdfUtils; import stirling.software.SPDF.utils.WebResponseUtils; @@ -29,22 +31,12 @@ public class OverlayImageController { summary = "Overlay image onto a PDF file", description = "This endpoint overlays an image onto a PDF file at the specified coordinates. The image can be overlaid on every page of the PDF if specified. Input:PDF/IMAGE Output:PDF Type:MF-SISO" ) - public ResponseEntity overlayImage( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file to overlay the image onto.", required = true) - MultipartFile pdfFile, - @RequestParam("fileInput2") - @Parameter(description = "The image file to be overlaid onto the PDF.", required = true) - MultipartFile imageFile, - @RequestParam("x") - @Parameter(description = "The x-coordinate at which to place the top-left corner of the image.", example = "0") - float x, - @RequestParam("y") - @Parameter(description = "The y-coordinate at which to place the top-left corner of the image.", example = "0") - float y, - @RequestParam("everyPage") - @Parameter(description = "Whether to overlay the image onto every page of the PDF.", example = "false") - boolean everyPage) { + public ResponseEntity overlayImage(@ModelAttribute OverlayImageRequest request) { + MultipartFile pdfFile = request.getFileInput(); + MultipartFile imageFile = request.getImageFile(); + float x = request.getX(); + float y = request.getY(); + boolean everyPage = request.isEveryPage(); try { byte[] pdfBytes = pdfFile.getBytes(); byte[] imageBytes = imageFile.getBytes(); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java index 2192d876..d1ecc9df 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java @@ -13,6 +13,7 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -22,6 +23,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.misc.AddPageNumbersRequest; import stirling.software.SPDF.utils.GeneralUtils; import stirling.software.SPDF.utils.WebResponseUtils; @@ -33,14 +35,13 @@ public class PageNumbersController { @PostMapping(value = "/add-page-numbers", consumes = "multipart/form-data") @Operation(summary = "Add page numbers to a PDF document", description = "This operation takes an input PDF file and adds page numbers to it. Input:PDF Output:PDF Type:SISO") - public ResponseEntity addPageNumbers( - @Parameter(description = "The input PDF file", required = true) @RequestParam("fileInput") MultipartFile file, - @Parameter(description = "Custom margin: small/medium/large", required = true, schema = @Schema(type = "string", allowableValues = {"small", "medium", "large"})) @RequestParam("customMargin") String customMargin, - @Parameter(description = "Position: 1 of 9 positions", required = true, schema = @Schema(type = "integer", minimum = "1", maximum = "9")) @RequestParam("position") int position, - @Parameter(description = "Starting number", required = true, schema = @Schema(type = "integer", minimum = "1")) @RequestParam("startingNumber") int startingNumber, - @Parameter(description = "Which pages to number, default all", required = false, schema = @Schema(type = "string")) @RequestParam(value = "pagesToNumber", required = false) String pagesToNumber, - @Parameter(description = "Custom text: defaults to just number but can have things like \"Page {n} of {p}\"", required = false, schema = @Schema(type = "string")) @RequestParam(value = "customText", required = false) String customText) - throws IOException { + public ResponseEntity addPageNumbers(@ModelAttribute AddPageNumbersRequest request) throws IOException { + MultipartFile file = request.getFileInput(); + String customMargin = request.getCustomMargin(); + int position = request.getPosition(); + int startingNumber = request.getStartingNumber(); + String pagesToNumber = request.getPagesToNumber(); + String customText = request.getCustomText(); int pageNumber = startingNumber; byte[] fileBytes = file.getBytes(); PDDocument document = PDDocument.load(fileBytes); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java index e9983902..819f8f70 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java @@ -9,6 +9,7 @@ import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -17,6 +18,8 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.PDFFile; +import stirling.software.SPDF.model.api.misc.AddPageNumbersRequest; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; @@ -32,11 +35,8 @@ public class RepairController { summary = "Repair a PDF file", description = "This endpoint repairs a given PDF file by running Ghostscript command. The PDF is first saved to a temporary location, repaired, read back, and then returned as a response. Input:PDF Output:PDF Type:SISO" ) - public ResponseEntity repairPdf( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file to be repaired", required = true) - MultipartFile inputFile) throws IOException, InterruptedException { - + public ResponseEntity repairPdf(@ModelAttribute PDFFile request) throws IOException, InterruptedException { + MultipartFile inputFile = request.getFileInput(); // Save the uploaded file to a temporary location Path tempInputFile = Files.createTempFile("input_", ".pdf"); inputFile.transferTo(tempInputFile.toFile()); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java index 08ac3e1b..d3101ff2 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java @@ -9,12 +9,14 @@ import org.apache.pdfbox.pdmodel.interactive.action.PDActionJavaScript; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @Tag(name = "Other", description = "Other APIs") @@ -22,9 +24,8 @@ public class ShowJavascript { private static final Logger logger = LoggerFactory.getLogger(ShowJavascript.class); @PostMapping(consumes = "multipart/form-data", value = "/show-javascript") - public ResponseEntity extractHeader( - @RequestPart(value = "fileInput") MultipartFile inputFile) throws Exception { - + public ResponseEntity extractHeader(@ModelAttribute PDFFile request) throws Exception { + MultipartFile inputFile = request.getFileInput(); String script = ""; try (PDDocument document = PDDocument.load(inputFile.getInputStream())) { diff --git a/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java b/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java index d5a50329..0e5d8de3 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java @@ -37,6 +37,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -51,6 +52,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.ApplicationProperties; import stirling.software.SPDF.model.PipelineConfig; import stirling.software.SPDF.model.PipelineOperation; +import stirling.software.SPDF.model.api.HandleDataRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @@ -418,8 +420,9 @@ public class PipelineController { } @PostMapping("/handleData") - public ResponseEntity handleData(@RequestPart("fileInput") MultipartFile[] files, - @RequestParam("json") String jsonString) { + public ResponseEntity handleData(@ModelAttribute HandleDataRequest request) { + MultipartFile[] files = request.getFileInputs(); + String jsonString = request.getJsonString(); logger.info("Received POST request to /handleData with {} files", files.length); try { List outputFiles = handleFiles(files, jsonString); 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 6392be96..d9eb68a3 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 @@ -44,6 +44,7 @@ import org.bouncycastle.util.io.pem.PemReader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -54,6 +55,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.security.SignPDFWithCertRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @@ -68,30 +70,18 @@ public class CertSignController { @PostMapping(consumes = "multipart/form-data", value = "/cert-sign") @Operation(summary = "Sign PDF with a Digital Certificate", description = "This endpoint accepts a PDF file, a digital certificate and related information to sign the PDF. It then returns the digitally signed PDF file. Input:PDF Output:PDF Type:MF-SISO") - public ResponseEntity signPDF2( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file") MultipartFile pdf, - - @RequestParam(value = "certType", required = false) @Parameter(description = "The type of the digital certificate", schema = @Schema(allowableValues = { - "PKCS12", "PEM" })) String certType, - - @RequestParam(value = "key", required = false) @Parameter(description = "The private key for the digital certificate (required for PEM type certificates)") MultipartFile privateKeyFile, - - @RequestParam(value = "cert", required = false) @Parameter(description = "The digital certificate (required for PEM type certificates)") MultipartFile certFile, - - @RequestParam(value = "p12", required = false) @Parameter(description = "The PKCS12 keystore file (required for PKCS12 type certificates)") MultipartFile p12File, - - @RequestParam(value = "password", required = false) @Parameter(description = "The password for the keystore or the private key") String password, - - @RequestParam(value = "showSignature", required = false) @Parameter(description = "Whether to visually show the signature in the PDF file") Boolean showSignature, - - @RequestParam(value = "reason", required = false) @Parameter(description = "The reason for signing the PDF") String reason, - - @RequestParam(value = "location", required = false) @Parameter(description = "The location where the PDF is signed") String location, - - @RequestParam(value = "name", required = false) @Parameter(description = "The name of the signer") String name, - - @RequestParam(value = "pageNumber", required = false) @Parameter(description = "The page number where the signature should be visible. This is required if showSignature is set to true") Integer pageNumber) - throws Exception { + public ResponseEntity signPDFWithCert(@ModelAttribute SignPDFWithCertRequest request) throws Exception { + MultipartFile pdf = request.getFileInput(); + String certType = request.getCertType(); + MultipartFile privateKeyFile = request.getPrivateKeyFile(); + MultipartFile certFile = request.getCertFile(); + MultipartFile p12File = request.getP12File(); + String password = request.getPassword(); + Boolean showSignature = request.getShowSignature(); + String reason = request.getReason(); + String location = request.getLocation(); + String name = request.getName(); + Integer pageNumber = request.getPageNumber(); PrivateKey privateKey = null; X509Certificate cert = null; diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java b/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java index 1f0e7d62..48f1c655 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java @@ -60,6 +60,7 @@ import org.apache.xmpbox.xml.XmpParsingException; import org.apache.xmpbox.xml.XmpSerializer; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -72,6 +73,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @Tag(name = "Security", description = "Security APIs") @@ -81,11 +83,9 @@ public class GetInfoOnPDF { @PostMapping(consumes = "multipart/form-data", value = "/get-info-on-pdf") @Operation(summary = "Summary here", description = "desc. Input:PDF Output:JSON Type:SISO") - public ResponseEntity getPdfInfo( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file to get info on", required = true) MultipartFile inputFile) + public ResponseEntity getPdfInfo(@ModelAttribute PDFFile request) throws IOException { - + MultipartFile inputFile = request.getFileInput(); try ( PDDocument pdfBoxDoc = PDDocument.load(inputFile.getInputStream()); ) { diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java index bcc7e37f..9634143b 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java @@ -8,6 +8,7 @@ import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -18,6 +19,8 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.security.AddPasswordRequest; +import stirling.software.SPDF.model.api.security.PDFPasswordRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @Tag(name = "Security", description = "Security APIs") @@ -31,13 +34,12 @@ public class PasswordController { summary = "Remove password from a PDF file", description = "This endpoint removes the password from a protected PDF file. Users need to provide the existing password. Input:PDF Output:PDF Type:SISO" ) - public ResponseEntity removePassword( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file from which the password should be removed", required = true) - MultipartFile fileInput, - @RequestParam(name = "password") - @Parameter(description = "The password of the PDF file", required = true) - String password) throws IOException { + public ResponseEntity removePassword(@ModelAttribute PDFPasswordRequest request) throws IOException { + MultipartFile fileInput = request.getFileInput(); + String password = request.getPassword(); + + + PDDocument document = PDDocument.load(fileInput.getBytes(), password); document.setAllSecurityToBeRemoved(true); return WebResponseUtils.pdfDocToWebResponse(document, fileInput.getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_password_removed.pdf"); @@ -48,44 +50,19 @@ public class PasswordController { summary = "Add password to a PDF file", description = "This endpoint adds password protection to a PDF file. Users can specify a set of permissions that should be applied to the file. Input:PDF Output:PDF" ) - public ResponseEntity addPassword( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file to which the password should be added", required = true) - MultipartFile fileInput, - @RequestParam(value = "", name = "ownerPassword", required = false, defaultValue = "") - @Parameter(description = "The owner password to be added to the PDF file (Restricts what can be done with the document once it is opened)") - String ownerPassword, - @RequestParam( name = "password", required = false, defaultValue = "") - @Parameter(description = "The password to be added to the PDF file (Restricts the opening of the document itself.)") - String password, - @RequestParam( name = "keyLength", required = false, defaultValue = "256") - @Parameter(description = "The length of the encryption key", schema = @Schema(allowableValues = {"40", "128", "256"})) - int keyLength, - @RequestParam( name = "canAssembleDocument", required = false) - @Parameter(description = "Whether the document assembly is allowed", example = "false") - boolean canAssembleDocument, - @RequestParam( name = "canExtractContent", required = false) - @Parameter(description = "Whether content extraction for accessibility is allowed", example = "false") - boolean canExtractContent, - @RequestParam( name = "canExtractForAccessibility", required = false) - @Parameter(description = "Whether content extraction for accessibility is allowed", example = "false") - boolean canExtractForAccessibility, - @RequestParam( name = "canFillInForm", required = false) - @Parameter(description = "Whether form filling is allowed", example = "false") - boolean canFillInForm, - @RequestParam( name = "canModify", required = false) - @Parameter(description = "Whether the document modification is allowed", example = "false") - boolean canModify, - @RequestParam( name = "canModifyAnnotations", required = false) - @Parameter(description = "Whether modification of annotations is allowed", example = "false") - boolean canModifyAnnotations, - @RequestParam(name = "canPrint", required = false) - @Parameter(description = "Whether printing of the document is allowed", example = "false") - boolean canPrint, - @RequestParam( name = "canPrintFaithful", required = false) - @Parameter(description = "Whether faithful printing is allowed", example = "false") - boolean canPrintFaithful - ) throws IOException { + public ResponseEntity addPassword(@ModelAttribute AddPasswordRequest request) throws IOException { + MultipartFile fileInput = request.getFileInput(); + String ownerPassword = request.getOwnerPassword(); + String password = request.getPassword(); + int keyLength = request.getKeyLength(); + boolean canAssembleDocument = request.isCanAssembleDocument(); + boolean canExtractContent = request.isCanExtractContent(); + boolean canExtractForAccessibility = request.isCanExtractForAccessibility(); + boolean canFillInForm = request.isCanFillInForm(); + boolean canModify = request.isCanModify(); + boolean canModifyAnnotations = request.isCanModifyAnnotations(); + boolean canPrint = request.isCanPrint(); + boolean canPrintFaithful = request.isCanPrintFaithful(); PDDocument document = PDDocument.load(fileInput.getBytes()); AccessPermission ap = new AccessPermission(); diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java b/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java index 006968ae..6c0a5526 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java @@ -18,6 +18,7 @@ import org.apache.pdfbox.rendering.PDFRenderer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -28,6 +29,7 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.PDFText; +import stirling.software.SPDF.model.api.security.RedactPdfRequest; import stirling.software.SPDF.pdf.TextFinder; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @@ -40,14 +42,14 @@ public class RedactController { @PostMapping(value = "/auto-redact", consumes = "multipart/form-data") @Operation(summary = "Redacts listOfText in a PDF document", description = "This operation takes an input PDF file and redacts the provided listOfText. Input:PDF, Output:PDF, Type:SISO") - public ResponseEntity redactPdf( - @Parameter(description = "The input PDF file", required = true) @RequestParam("fileInput") MultipartFile file, - @Parameter(description = "List of listOfText to redact from the PDF", required = true, schema = @Schema(type = "string")) @RequestParam("listOfText") String listOfTextString, - @RequestParam(value = "useRegex", required = false) boolean useRegex, - @RequestParam(value = "wholeWordSearch", required = false) boolean wholeWordSearchBool, - @RequestParam(value = "redactColor", required = false, defaultValue = "#000000") String colorString, - @RequestParam(value = "customPadding", required = false) float customPadding, - @RequestParam(value = "convertPDFToImage", required = false) boolean convertPDFToImage) throws Exception { + public ResponseEntity redactPdf(@ModelAttribute RedactPdfRequest request) throws Exception { + MultipartFile file = request.getFileInput(); + String listOfTextString = request.getListOfText(); + boolean useRegex = request.isUseRegex(); + boolean wholeWordSearchBool = request.isWholeWordSearch(); + String colorString = request.getRedactColor(); + float customPadding = request.getCustomPadding(); + boolean convertPDFToImage = request.isConvertPDFToImage(); System.out.println(listOfTextString); String[] listOfText = listOfTextString.split("\n"); diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java index fa49c6ad..ccf088de 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java @@ -20,6 +20,7 @@ import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget; import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm; import org.apache.pdfbox.pdmodel.interactive.form.PDField; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -28,6 +29,7 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import stirling.software.SPDF.model.api.security.SanitizePdfRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @@ -36,25 +38,13 @@ public class SanitizeController { @PostMapping(consumes = "multipart/form-data", value = "/sanitize-pdf") @Operation(summary = "Sanitize a PDF file", description = "This endpoint processes a PDF file and removes specific elements based on the provided options. Input:PDF Output:PDF Type:SISO") - public ResponseEntity sanitizePDF( - @RequestPart(required = true, value = "fileInput") - @Parameter(description = "The input PDF file to be sanitized") - MultipartFile inputFile, - @RequestParam(name = "removeJavaScript", required = false, defaultValue = "false") - @Parameter(description = "Remove JavaScript actions from the PDF if set to true") - Boolean removeJavaScript, - @RequestParam(name = "removeEmbeddedFiles", required = false, defaultValue = "false") - @Parameter(description = "Remove embedded files from the PDF if set to true") - Boolean removeEmbeddedFiles, - @RequestParam(name = "removeMetadata", required = false, defaultValue = "false") - @Parameter(description = "Remove metadata from the PDF if set to true") - Boolean removeMetadata, - @RequestParam(name = "removeLinks", required = false, defaultValue = "false") - @Parameter(description = "Remove links from the PDF if set to true") - Boolean removeLinks, - @RequestParam(name = "removeFonts", required = false, defaultValue = "false") - @Parameter(description = "Remove fonts from the PDF if set to true") - Boolean removeFonts) throws IOException { + public ResponseEntity sanitizePDF(@ModelAttribute SanitizePdfRequest request) throws IOException { + MultipartFile inputFile = request.getFileInput(); + Boolean removeJavaScript = request.getRemoveJavaScript(); + Boolean removeEmbeddedFiles = request.getRemoveEmbeddedFiles(); + Boolean removeMetadata = request.getRemoveMetadata(); + Boolean removeLinks = request.getRemoveLinks(); + Boolean removeFonts = request.getRemoveFonts(); try (PDDocument document = PDDocument.load(inputFile.getInputStream())) { if (removeJavaScript) { diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java index efc263f5..a46f4ff4 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java @@ -22,6 +22,7 @@ import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState; import org.apache.pdfbox.util.Matrix; import org.springframework.core.io.ClassPathResource; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; @@ -32,6 +33,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import stirling.software.SPDF.model.api.security.AddWatermarkRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @@ -40,22 +42,17 @@ public class WatermarkController { @PostMapping(consumes = "multipart/form-data", value = "/add-watermark") @Operation(summary = "Add watermark to a PDF file", description = "This endpoint adds a watermark to a given PDF file. Users can specify the watermark type (text or image), rotation, opacity, width spacer, and height spacer. Input:PDF Output:PDF Type:SISO") - public ResponseEntity addWatermark( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file to add a watermark") MultipartFile pdfFile, - @RequestParam(required = true) @Parameter(description = "The watermark type (text or image)") String watermarkType, - @RequestParam(required = false) @Parameter(description = "The watermark text") String watermarkText, - @RequestPart(required = false) @Parameter(description = "The watermark image") MultipartFile watermarkImage, - - @RequestParam(defaultValue = "roman", name = "alphabet") @Parameter(description = "The selected alphabet", - schema = @Schema(type = "string", - allowableValues = {"roman","arabic","japanese","korean","chinese"}, - defaultValue = "roman")) String alphabet, - @RequestParam(defaultValue = "30", name = "fontSize") @Parameter(description = "The font size of the watermark text", example = "30") float fontSize, - @RequestParam(defaultValue = "0", name = "rotation") @Parameter(description = "The rotation of the watermark in degrees", example = "0") float rotation, - @RequestParam(defaultValue = "0.5", name = "opacity") @Parameter(description = "The opacity of the watermark (0.0 - 1.0)", example = "0.5") float opacity, - @RequestParam(defaultValue = "50", name = "widthSpacer") @Parameter(description = "The width spacer between watermark elements", example = "50") int widthSpacer, - @RequestParam(defaultValue = "50", name = "heightSpacer") @Parameter(description = "The height spacer between watermark elements", example = "50") int heightSpacer) - throws IOException, Exception { + public ResponseEntity addWatermark(@ModelAttribute AddWatermarkRequest request) throws IOException, Exception { + MultipartFile pdfFile = request.getFileInput(); + String watermarkType = request.getWatermarkType(); + String watermarkText = request.getWatermarkText(); + MultipartFile watermarkImage = request.getWatermarkImage(); + String alphabet = request.getAlphabet(); + float fontSize = request.getFontSize(); + float rotation = request.getRotation(); + float opacity = request.getOpacity(); + int widthSpacer = request.getWidthSpacer(); + int heightSpacer = request.getHeightSpacer(); // Load the input PDF PDDocument document = PDDocument.load(pdfFile.getInputStream()); diff --git a/src/main/java/stirling/software/SPDF/model/api/HandleDataRequest.java b/src/main/java/stirling/software/SPDF/model/api/HandleDataRequest.java new file mode 100644 index 00000000..d22c8f67 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/HandleDataRequest.java @@ -0,0 +1,15 @@ +package stirling.software.SPDF.model.api; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +@Data +public class HandleDataRequest { + + @Schema(description = "The input files") + private MultipartFile[] fileInputs; + + @Schema(description = "JSON String") + private String jsonString; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/AddPageNumbersRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/AddPageNumbersRequest.java new file mode 100644 index 00000000..e258b59a --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/misc/AddPageNumbersRequest.java @@ -0,0 +1,26 @@ +package stirling.software.SPDF.model.api.misc; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFWithPageNums; + +import org.springframework.web.multipart.MultipartFile; + +@Data +public class AddPageNumbersRequest extends PDFWithPageNums { + + @Schema(description = "Custom margin: small/medium/large", allowableValues = {"small", "medium", "large"}) + private String customMargin; + + @Schema(description = "Position: 1 of 9 positions", minimum = "1", maximum = "9") + private int position; + + @Schema(description = "Starting number", minimum = "1") + private int startingNumber; + + @Schema(description = "Which pages to number, default all") + private String pagesToNumber; + + @Schema(description = "Custom text: defaults to just number but can have things like \"Page {n} of {p}\"") + private String customText; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/OverlayImageRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/OverlayImageRequest.java new file mode 100644 index 00000000..29350519 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/misc/OverlayImageRequest.java @@ -0,0 +1,23 @@ +package stirling.software.SPDF.model.api.misc; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import stirling.software.SPDF.model.api.PDFFile; + +import org.springframework.web.multipart.MultipartFile; + +@Data +public class OverlayImageRequest extends PDFFile { + + @Schema(description = "The image file to be overlaid onto the PDF.") + private MultipartFile imageFile; + + @Schema(description = "The x-coordinate at which to place the top-left corner of the image.", example = "0") + private float x; + + @Schema(description = "The y-coordinate at which to place the top-left corner of the image.", example = "0") + private float y; + + @Schema(description = "Whether to overlay the image onto every page of the PDF.", example = "false") + private boolean everyPage; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java new file mode 100644 index 00000000..a332a7ff --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java @@ -0,0 +1,36 @@ +package stirling.software.SPDF.model.api.misc; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; +import stirling.software.SPDF.model.api.PDFFile; + +import java.util.List; + +@Data +public class ProcessPdfWithOcrRequest extends PDFFile { + + @Schema(description = "List of languages to use in OCR processing") + private List selectedLanguages; + + @Schema(description = "Include OCR text in a sidecar text file if set to true") + private Boolean sidecar; + + @Schema(description = "Deskew the input file if set to true") + private Boolean deskew; + + @Schema(description = "Clean the input file if set to true") + private Boolean clean; + + @Schema(description = "Clean the final output if set to true") + private Boolean cleanFinal; + + @Schema(description = "Specify the OCR type, e.g., 'skip-text', 'force-ocr', or 'Normal'", allowableValues = {"skip-text", "force-ocr", "Normal"}) + private String ocrType; + + @Schema(description = "Specify the OCR render type, either 'hocr' or 'sandwich'", allowableValues = {"hocr", "sandwich"}, defaultValue = "hocr") + private String ocrRenderType; + + @Schema(description = "Remove images from the output PDF if set to true") + private Boolean removeImagesAfter; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/security/AddPasswordRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/AddPasswordRequest.java new file mode 100644 index 00000000..60bbcc6b --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/security/AddPasswordRequest.java @@ -0,0 +1,43 @@ +package stirling.software.SPDF.model.api.security; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class AddPasswordRequest extends PDFFile { + + @Schema(description = "The owner password to be added to the PDF file (Restricts what can be done with the document once it is opened)", defaultValue = "") + private String ownerPassword; + + @Schema(description = "The password to be added to the PDF file (Restricts the opening of the document itself.)", defaultValue = "") + private String password; + + @Schema(description = "The length of the encryption key", allowableValues = {"40", "128", "256"}, defaultValue = "256") + private int keyLength; + + @Schema(description = "Whether the document assembly is allowed", example = "false") + private boolean canAssembleDocument; + + @Schema(description = "Whether content extraction for accessibility is allowed", example = "false") + private boolean canExtractContent; + + @Schema(description = "Whether content extraction for accessibility is allowed", example = "false") + private boolean canExtractForAccessibility; + + @Schema(description = "Whether form filling is allowed", example = "false") + private boolean canFillInForm; + + @Schema(description = "Whether the document modification is allowed", example = "false") + private boolean canModify; + + @Schema(description = "Whether modification of annotations is allowed", example = "false") + private boolean canModifyAnnotations; + + @Schema(description = "Whether printing of the document is allowed", example = "false") + private boolean canPrint; + + @Schema(description = "Whether faithful printing is allowed", example = "false") + private boolean canPrintFaithful; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/security/AddWatermarkRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/AddWatermarkRequest.java new file mode 100644 index 00000000..42d34af4 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/security/AddWatermarkRequest.java @@ -0,0 +1,39 @@ +package stirling.software.SPDF.model.api.security; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class AddWatermarkRequest extends PDFFile { + + @Schema(description = "The watermark type (text or image)", required = true) + private String watermarkType; + + @Schema(description = "The watermark text") + private String watermarkText; + + @Schema(description = "The watermark image") + private MultipartFile watermarkImage; + + @Schema(description = "The selected alphabet", + allowableValues = {"roman", "arabic", "japanese", "korean", "chinese"}, + defaultValue = "roman") + private String alphabet; + + @Schema(description = "The font size of the watermark text", example = "30") + private float fontSize; + + @Schema(description = "The rotation of the watermark in degrees", example = "0") + private float rotation; + + @Schema(description = "The opacity of the watermark (0.0 - 1.0)", example = "0.5") + private float opacity; + + @Schema(description = "The width spacer between watermark elements", example = "50") + private int widthSpacer; + + @Schema(description = "The height spacer between watermark elements", example = "50") + private int heightSpacer; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/security/PDFPasswordRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/PDFPasswordRequest.java new file mode 100644 index 00000000..c1acd32c --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/security/PDFPasswordRequest.java @@ -0,0 +1,13 @@ +package stirling.software.SPDF.model.api.security; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class PDFPasswordRequest extends PDFFile { + + @Schema(description = "The password of the PDF file", required = true) + private String password; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/security/RedactPdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/RedactPdfRequest.java new file mode 100644 index 00000000..fff02ff5 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/security/RedactPdfRequest.java @@ -0,0 +1,28 @@ +package stirling.software.SPDF.model.api.security; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class RedactPdfRequest extends PDFFile { + + @Schema(description = "List of text to redact from the PDF", type = "string", required = true) + private String listOfText; + + @Schema(description = "Whether to use regex for the listOfText", defaultValue = "false") + private boolean useRegex; + + @Schema(description = "Whether to use whole word search", defaultValue = "false") + private boolean wholeWordSearch; + + @Schema(description = "The color for redaction", defaultValue = "#000000") + private String redactColor; + + @Schema(description = "Custom padding for redaction", type = "number") + private float customPadding; + + @Schema(description = "Convert the redacted PDF to an image", defaultValue = "false") + private boolean convertPDFToImage; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/security/SanitizePdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/SanitizePdfRequest.java new file mode 100644 index 00000000..280f2021 --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/security/SanitizePdfRequest.java @@ -0,0 +1,25 @@ +package stirling.software.SPDF.model.api.security; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class SanitizePdfRequest extends PDFFile { + + @Schema(description = "Remove JavaScript actions from the PDF", defaultValue = "false") + private Boolean removeJavaScript; + + @Schema(description = "Remove embedded files from the PDF", defaultValue = "false") + private Boolean removeEmbeddedFiles; + + @Schema(description = "Remove metadata from the PDF", defaultValue = "false") + private Boolean removeMetadata; + + @Schema(description = "Remove links from the PDF", defaultValue = "false") + private Boolean removeLinks; + + @Schema(description = "Remove fonts from the PDF", defaultValue = "false") + private Boolean removeFonts; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/security/SignPDFWithCertRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/SignPDFWithCertRequest.java new file mode 100644 index 00000000..5344bf4d --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/security/SignPDFWithCertRequest.java @@ -0,0 +1,40 @@ +package stirling.software.SPDF.model.api.security; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; +import stirling.software.SPDF.model.api.PDFFile; + +@Data +public class SignPDFWithCertRequest extends PDFFile { + + @Schema(description = "The type of the digital certificate", allowableValues = { "PKCS12", "PEM" }) + private String certType; + + @Schema(description = "The private key for the digital certificate (required for PEM type certificates)") + private MultipartFile privateKeyFile; + + @Schema(description = "The digital certificate (required for PEM type certificates)") + private MultipartFile certFile; + + @Schema(description = "The PKCS12 keystore file (required for PKCS12 type certificates)") + private MultipartFile p12File; + + @Schema(description = "The password for the keystore or the private key") + private String password; + + @Schema(description = "Whether to visually show the signature in the PDF file") + private Boolean showSignature; + + @Schema(description = "The reason for signing the PDF") + private String reason; + + @Schema(description = "The location where the PDF is signed") + private String location; + + @Schema(description = "The name of the signer") + private String name; + + @Schema(description = "The page number where the signature should be visible. This is required if showSignature is set to true") + private Integer pageNumber; +} From 80b4c67e3547f9f81d9647d7c0d72afa83d55b0c Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sun, 10 Sep 2023 09:24:20 +0100 Subject: [PATCH 05/13] super call --- .../software/SPDF/controller/api/CropController.java | 4 ---- .../software/SPDF/controller/api/MergeController.java | 5 ----- .../controller/api/MultiPageLayoutController.java | 3 --- .../controller/api/RearrangePagesPDFController.java | 5 ++--- .../SPDF/controller/api/RotationController.java | 3 --- .../SPDF/controller/api/ScalePagesController.java | 3 --- .../SPDF/controller/api/SplitPDFController.java | 4 ---- .../SPDF/controller/api/ToSinglePageController.java | 3 --- .../controller/api/converters/ConvertEpubToPdf.java | 2 -- .../controller/api/converters/ConvertHtmlToPDF.java | 3 --- .../api/converters/ConvertImgPDFController.java | 4 ---- .../api/converters/ConvertMarkdownToPdf.java | 3 --- .../api/converters/ConvertOfficeController.java | 2 -- .../controller/api/converters/ConvertPDFToOffice.java | 5 ----- .../controller/api/converters/ConvertPDFToPDFA.java | 3 --- .../api/converters/ConvertWebsiteToPDF.java | 2 -- .../SPDF/controller/api/filters/FilterController.java | 3 --- .../controller/api/misc/AutoRenameController.java | 3 --- .../controller/api/misc/AutoSplitPdfController.java | 2 -- .../SPDF/controller/api/misc/BlankPageController.java | 3 --- .../SPDF/controller/api/misc/CompressController.java | 4 ---- .../api/misc/ExtractImageScansController.java | 8 ++------ .../controller/api/misc/ExtractImagesController.java | 4 ---- .../controller/api/misc/FakeScanControllerWIP.java | 2 -- .../SPDF/controller/api/misc/MetadataController.java | 3 --- .../SPDF/controller/api/misc/OCRController.java | 4 ---- .../controller/api/misc/OverlayImageController.java | 3 --- .../controller/api/misc/PageNumbersController.java | 3 --- .../SPDF/controller/api/misc/RepairController.java | 3 --- .../SPDF/controller/api/misc/ShowJavascript.java | 1 - .../controller/api/pipeline/PipelineController.java | 2 -- .../controller/api/security/CertSignController.java | 4 ---- .../SPDF/controller/api/security/GetInfoOnPDF.java | 2 -- .../controller/api/security/PasswordController.java | 4 ---- .../controller/api/security/RedactController.java | 3 --- .../controller/api/security/SanitizeController.java | 3 --- .../controller/api/security/WatermarkController.java | 4 ---- .../SPDF/controller/web/GeneralWebController.java | 4 +++- .../stirling/software/SPDF/model/api/GeneralFile.java | 4 ++++ .../software/SPDF/model/api/HandleDataRequest.java | 7 ++++++- .../stirling/software/SPDF/model/api/ImageFile.java | 4 ++++ .../software/SPDF/model/api/MultiplePDFFiles.java | 4 ++++ .../software/SPDF/model/api/PDFComparison.java | 7 ++----- .../SPDF/model/api/PDFComparisonAndCount.java | 7 ++----- .../stirling/software/SPDF/model/api/PDFFile.java | 2 ++ .../SPDF/model/api/PDFWithImageFormatRequest.java | 2 ++ .../software/SPDF/model/api/PDFWithPageNums.java | 3 +++ .../model/api/converters/ConvertToImageRequest.java | 3 ++- .../model/api/converters/ConvertToPdfRequest.java | 5 ++++- .../api/converters/PdfToPresentationRequest.java | 3 ++- .../model/api/converters/PdfToTextOrRTFRequest.java | 2 ++ .../SPDF/model/api/converters/PdfToWordRequest.java | 2 ++ .../SPDF/model/api/converters/UrlToPdfRequest.java | 2 ++ .../SPDF/model/api/filter/ContainsTextRequest.java | 2 ++ .../SPDF/model/api/filter/FileSizeRequest.java | 3 ++- .../SPDF/model/api/filter/PageRotationRequest.java | 3 ++- .../SPDF/model/api/filter/PageSizeRequest.java | 3 ++- .../software/SPDF/model/api/general/CropPdfForm.java | 8 +++----- .../model/api/general/MergeMultiplePagesRequest.java | 2 ++ .../SPDF/model/api/general/MergePdfsRequest.java | 2 ++ .../SPDF/model/api/general/RearrangePagesRequest.java | 6 +++--- .../SPDF/model/api/general/RotatePDFRequest.java | 3 ++- .../SPDF/model/api/general/ScalePagesRequest.java | 3 ++- .../SPDF/model/api/misc/AddPageNumbersRequest.java | 4 ++-- .../SPDF/model/api/misc/AutoSplitPdfRequest.java | 2 ++ .../SPDF/model/api/misc/ExtractHeaderRequest.java | 2 ++ .../SPDF/model/api/misc/ExtractImageScansRequest.java | 2 ++ .../software/SPDF/model/api/misc/MetadataRequest.java | 10 ++++++---- .../SPDF/model/api/misc/OptimizePdfRequest.java | 2 ++ .../SPDF/model/api/misc/OverlayImageRequest.java | 10 ++++++---- .../SPDF/model/api/misc/ProcessPdfWithOcrRequest.java | 11 ++++++----- .../SPDF/model/api/misc/RemoveBlankPagesRequest.java | 2 ++ .../SPDF/model/api/security/AddPasswordRequest.java | 3 ++- .../SPDF/model/api/security/AddWatermarkRequest.java | 5 ++++- .../SPDF/model/api/security/PDFPasswordRequest.java | 3 ++- .../SPDF/model/api/security/RedactPdfRequest.java | 3 ++- .../SPDF/model/api/security/SanitizePdfRequest.java | 3 ++- .../model/api/security/SignPDFWithCertRequest.java | 5 ++++- 78 files changed, 118 insertions(+), 167 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/controller/api/CropController.java b/src/main/java/stirling/software/SPDF/controller/api/CropController.java index 38d68420..008f21bf 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/CropController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/CropController.java @@ -15,13 +15,9 @@ import org.slf4j.LoggerFactory; 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.RequestParam; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.general.CropPdfForm; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/MergeController.java b/src/main/java/stirling/software/SPDF/controller/api/MergeController.java index 03bf4066..df0e553b 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/MergeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/MergeController.java @@ -17,16 +17,11 @@ import org.slf4j.LoggerFactory; 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; -import stirling.software.SPDF.model.api.general.CropPdfForm; import stirling.software.SPDF.model.api.general.MergePdfsRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java index 12c262cd..99558886 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java @@ -16,13 +16,10 @@ import org.slf4j.LoggerFactory; 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.RequestParam; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.general.MergeMultiplePagesRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java index 294df38d..6d8a7a8f 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java @@ -18,12 +18,11 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; -import stirling.software.SPDF.utils.GeneralUtils; -import stirling.software.SPDF.utils.WebResponseUtils; import stirling.software.SPDF.model.SortTypes; import stirling.software.SPDF.model.api.general.RearrangePagesRequest; +import stirling.software.SPDF.utils.GeneralUtils; +import stirling.software.SPDF.utils.WebResponseUtils; @RestController @Tag(name = "General", description = "General APIs") public class RearrangePagesPDFController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/RotationController.java b/src/main/java/stirling/software/SPDF/controller/api/RotationController.java index ef32df4e..04011ee9 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RotationController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RotationController.java @@ -10,13 +10,10 @@ import org.slf4j.LoggerFactory; 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.general.RotatePDFRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java index 2dcb26af..2a102858 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java @@ -17,13 +17,10 @@ import org.slf4j.LoggerFactory; 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.RequestParam; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.general.ScalePagesRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java index fe3a1cc5..90279962 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java @@ -19,16 +19,12 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFWithPageNums; -import stirling.software.SPDF.utils.GeneralUtils; import stirling.software.SPDF.utils.WebResponseUtils; @RestController diff --git a/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java b/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java index ea64d55b..f645c319 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java @@ -15,12 +15,9 @@ import org.slf4j.LoggerFactory; 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.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java index 77262cce..366eb8da 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java @@ -16,7 +16,6 @@ import javax.xml.parsers.DocumentBuilderFactory; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import org.w3c.dom.Document; @@ -28,7 +27,6 @@ import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.GeneralFile; -import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.FileToPdf; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java index d9308d09..a333e2f1 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java @@ -1,11 +1,8 @@ package stirling.software.SPDF.controller.api.converters; -import java.io.IOException; - 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java index 5a4dab2c..e24df3a2 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java @@ -13,14 +13,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.converters.ConvertToImageRequest; import stirling.software.SPDF.model.api.converters.ConvertToPdfRequest; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java index 02ff1e27..87c831ad 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java @@ -1,14 +1,11 @@ package stirling.software.SPDF.controller.api.converters; -import java.io.IOException; - import org.commonmark.node.Node; import org.commonmark.parser.Parser; import org.commonmark.renderer.html.HtmlRenderer; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java index 9ee5cdd5..8f732e58 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java @@ -12,12 +12,10 @@ import org.apache.commons.io.FilenameUtils; 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.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.GeneralFile; import stirling.software.SPDF.utils.ProcessExecutor; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java index b61549ff..40cdc6d5 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java @@ -5,16 +5,11 @@ import java.io.IOException; 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; -import stirling.software.SPDF.model.api.GeneralFile; import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.model.api.converters.PdfToPresentationRequest; import stirling.software.SPDF.model.api.converters.PdfToTextOrRTFRequest; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java index ca83d4ed..7e95e311 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.converters; -import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -9,12 +8,10 @@ import java.util.List; 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.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.ProcessExecutor; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java index 3d4fd368..f9d8e584 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java @@ -9,11 +9,9 @@ import java.util.List; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.converters.UrlToPdfRequest; import stirling.software.SPDF.utils.GeneralUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java b/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java index dbb20bfe..ce3fc651 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java @@ -8,13 +8,10 @@ import org.apache.pdfbox.pdmodel.common.PDRectangle; 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.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFComparisonAndCount; import stirling.software.SPDF.model.api.PDFWithPageNums; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java index 8059062c..c1f204ba 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java @@ -13,13 +13,10 @@ import org.slf4j.LoggerFactory; 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.ExtractHeaderRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java index 3ba81f78..59a2777f 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java @@ -18,7 +18,6 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -31,7 +30,6 @@ import com.google.zxing.Result; import com.google.zxing.common.HybridBinarizer; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import stirling.software.SPDF.model.api.misc.AutoSplitPdfRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java index 5107d8c0..a8025af9 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java @@ -22,13 +22,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.RemoveBlankPagesRequest; import stirling.software.SPDF.utils.PdfUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java index 89147056..188689a1 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java @@ -24,14 +24,10 @@ import org.slf4j.LoggerFactory; 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.OptimizePdfRequest; import stirling.software.SPDF.utils.GeneralUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java index 5a1bbf8a..51c02084 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java @@ -24,21 +24,17 @@ import org.slf4j.LoggerFactory; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.ExtractImageScansRequest; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; @RestController @Tag(name = "Other", description = "Other APIs") public class ExtractImageScansController { 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 91bbff09..ac6b1b99 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 @@ -22,14 +22,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFWithImageFormatRequest; import stirling.software.SPDF.utils.WebResponseUtils; 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 70fc2e88..270f9615 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 @@ -32,13 +32,11 @@ import org.slf4j.LoggerFactory; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java index aa9b5395..3b3ccb5c 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java @@ -13,13 +13,10 @@ import org.apache.pdfbox.pdmodel.PDDocumentInformation; 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.MetadataRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java index aa25b9b4..8c646809 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java @@ -20,14 +20,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.ProcessPdfWithOcrRequest; import stirling.software.SPDF.utils.ProcessExecutor; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java index 44c16fd7..47829221 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java @@ -8,13 +8,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.OverlayImageRequest; import stirling.software.SPDF.utils.PdfUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java index d1ecc9df..cee21db8 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java @@ -15,13 +15,10 @@ 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.RequestParam; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.AddPageNumbersRequest; import stirling.software.SPDF.utils.GeneralUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java index 819f8f70..f713d4b1 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java @@ -11,15 +11,12 @@ import org.slf4j.LoggerFactory; 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.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFFile; -import stirling.software.SPDF.model.api.misc.AddPageNumbersRequest; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java index d3101ff2..9558115c 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java @@ -11,7 +11,6 @@ import org.slf4j.LoggerFactory; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; diff --git a/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java b/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java index 0e5d8de3..f300b0a6 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java @@ -39,8 +39,6 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; 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 d9eb68a3..a5054a6c 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 @@ -46,14 +46,10 @@ import org.slf4j.LoggerFactory; 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.security.SignPDFWithCertRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java b/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java index 48f1c655..53c9744e 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java @@ -62,7 +62,6 @@ 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -71,7 +70,6 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java index 9634143b..ad323849 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java @@ -10,14 +10,10 @@ import org.slf4j.LoggerFactory; 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.security.AddPasswordRequest; import stirling.software.SPDF.model.api.security.PDFPasswordRequest; diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java b/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java index 6c0a5526..2f946ec4 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java @@ -20,13 +20,10 @@ import org.slf4j.LoggerFactory; 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.RequestParam; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.PDFText; import stirling.software.SPDF.model.api.security.RedactPdfRequest; diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java index ccf088de..33afd430 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java @@ -22,13 +22,10 @@ import org.apache.pdfbox.pdmodel.interactive.form.PDField; 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import stirling.software.SPDF.model.api.security.SanitizePdfRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java index a46f4ff4..2fe52ab1 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java @@ -24,14 +24,10 @@ import org.springframework.core.io.ClassPathResource; 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.security.AddWatermarkRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java b/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java index e04626da..2571c785 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java @@ -21,6 +21,7 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.v3.oas.annotations.Hidden; @@ -51,7 +52,8 @@ public class GeneralWebController { } List> pipelineConfigsWithNames = new ArrayList<>(); for (String config : pipelineConfigs) { - Map jsonContent = new ObjectMapper().readValue(config, Map.class); + Map jsonContent = new ObjectMapper().readValue(config, new TypeReference>(){}); + String name = (String) jsonContent.get("name"); Map configWithName = new HashMap<>(); configWithName.put("json", config); diff --git a/src/main/java/stirling/software/SPDF/model/api/GeneralFile.java b/src/main/java/stirling/software/SPDF/model/api/GeneralFile.java index 84710585..441d904a 100644 --- a/src/main/java/stirling/software/SPDF/model/api/GeneralFile.java +++ b/src/main/java/stirling/software/SPDF/model/api/GeneralFile.java @@ -4,8 +4,12 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; @Data +@EqualsAndHashCode +@NoArgsConstructor public class GeneralFile { @Schema(description = "The input file") diff --git a/src/main/java/stirling/software/SPDF/model/api/HandleDataRequest.java b/src/main/java/stirling/software/SPDF/model/api/HandleDataRequest.java index d22c8f67..1d7a8afe 100644 --- a/src/main/java/stirling/software/SPDF/model/api/HandleDataRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/HandleDataRequest.java @@ -1,10 +1,15 @@ package stirling.software.SPDF.model.api; +import org.springframework.web.multipart.MultipartFile; + import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import org.springframework.web.multipart.MultipartFile; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; @Data +@NoArgsConstructor +@EqualsAndHashCode public class HandleDataRequest { @Schema(description = "The input files") diff --git a/src/main/java/stirling/software/SPDF/model/api/ImageFile.java b/src/main/java/stirling/software/SPDF/model/api/ImageFile.java index 8c4c0cff..02079843 100644 --- a/src/main/java/stirling/software/SPDF/model/api/ImageFile.java +++ b/src/main/java/stirling/software/SPDF/model/api/ImageFile.java @@ -4,8 +4,12 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; @Data +@NoArgsConstructor +@EqualsAndHashCode public class ImageFile { @Schema(description = "The input image file") private MultipartFile fileInput; diff --git a/src/main/java/stirling/software/SPDF/model/api/MultiplePDFFiles.java b/src/main/java/stirling/software/SPDF/model/api/MultiplePDFFiles.java index 17bec404..937a4265 100644 --- a/src/main/java/stirling/software/SPDF/model/api/MultiplePDFFiles.java +++ b/src/main/java/stirling/software/SPDF/model/api/MultiplePDFFiles.java @@ -4,7 +4,11 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; @Data +@NoArgsConstructor +@EqualsAndHashCode public class MultiplePDFFiles { @Schema(description = "The input PDF files", type = "array", format = "binary") private MultipartFile[] fileInput; diff --git a/src/main/java/stirling/software/SPDF/model/api/PDFComparison.java b/src/main/java/stirling/software/SPDF/model/api/PDFComparison.java index 5d7871b0..1f902d88 100644 --- a/src/main/java/stirling/software/SPDF/model/api/PDFComparison.java +++ b/src/main/java/stirling/software/SPDF/model/api/PDFComparison.java @@ -1,15 +1,12 @@ package stirling.software.SPDF.model.api; -import java.io.IOException; -import java.util.List; - -import org.apache.pdfbox.pdmodel.PDDocument; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import stirling.software.SPDF.utils.GeneralUtils; @Data @NoArgsConstructor +@EqualsAndHashCode(callSuper=true) public class PDFComparison extends PDFFile { @Schema(description = "The comparison type, accepts Greater, Equal, Less than", allowableValues = { diff --git a/src/main/java/stirling/software/SPDF/model/api/PDFComparisonAndCount.java b/src/main/java/stirling/software/SPDF/model/api/PDFComparisonAndCount.java index 8779ba57..14462f0a 100644 --- a/src/main/java/stirling/software/SPDF/model/api/PDFComparisonAndCount.java +++ b/src/main/java/stirling/software/SPDF/model/api/PDFComparisonAndCount.java @@ -1,15 +1,12 @@ package stirling.software.SPDF.model.api; -import java.io.IOException; -import java.util.List; - -import org.apache.pdfbox.pdmodel.PDDocument; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import stirling.software.SPDF.utils.GeneralUtils; @Data @NoArgsConstructor +@EqualsAndHashCode(callSuper=true) public class PDFComparisonAndCount extends PDFComparison { @Schema(description = "Count") private String pageCount; diff --git a/src/main/java/stirling/software/SPDF/model/api/PDFFile.java b/src/main/java/stirling/software/SPDF/model/api/PDFFile.java index 0b304747..378b3c03 100644 --- a/src/main/java/stirling/software/SPDF/model/api/PDFFile.java +++ b/src/main/java/stirling/software/SPDF/model/api/PDFFile.java @@ -4,7 +4,9 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode public class PDFFile { @Schema(description = "The input PDF file") private MultipartFile fileInput; diff --git a/src/main/java/stirling/software/SPDF/model/api/PDFWithImageFormatRequest.java b/src/main/java/stirling/software/SPDF/model/api/PDFWithImageFormatRequest.java index 9766fdbf..aa8fe08b 100644 --- a/src/main/java/stirling/software/SPDF/model/api/PDFWithImageFormatRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/PDFWithImageFormatRequest.java @@ -2,8 +2,10 @@ package stirling.software.SPDF.model.api; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode(callSuper=true) public class PDFWithImageFormatRequest extends PDFFile { @Schema(description = "The output image format e.g., 'png', 'jpeg', or 'gif'", diff --git a/src/main/java/stirling/software/SPDF/model/api/PDFWithPageNums.java b/src/main/java/stirling/software/SPDF/model/api/PDFWithPageNums.java index 4de315de..d53d8d12 100644 --- a/src/main/java/stirling/software/SPDF/model/api/PDFWithPageNums.java +++ b/src/main/java/stirling/software/SPDF/model/api/PDFWithPageNums.java @@ -4,12 +4,15 @@ import java.io.IOException; import java.util.List; import org.apache.pdfbox.pdmodel.PDDocument; + import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import stirling.software.SPDF.utils.GeneralUtils; @Data @NoArgsConstructor +@EqualsAndHashCode(callSuper=true) public class PDFWithPageNums extends PDFFile { @Schema(description = "The pages to select, Supports ranges (e.g., '1,3,5-9'), or 'all' or functions in the format 'an+b' where 'a' is the multiplier of the page number 'n', and 'b' is a constant (e.g., '2n+1', '3n', '6n-5')\"") diff --git a/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToImageRequest.java b/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToImageRequest.java index 34e36379..18026618 100644 --- a/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToImageRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToImageRequest.java @@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.converters; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import org.springframework.web.multipart.MultipartFile; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class ConvertToImageRequest extends PDFFile { @Schema(description = "The output image format", allowableValues = {"png", "jpeg", "jpg", "gif"}) diff --git a/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToPdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToPdfRequest.java index 90325ed6..dba2dc5e 100644 --- a/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToPdfRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/converters/ConvertToPdfRequest.java @@ -1,10 +1,13 @@ package stirling.software.SPDF.model.api.converters; +import org.springframework.web.multipart.MultipartFile; + import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import org.springframework.web.multipart.MultipartFile; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode public class ConvertToPdfRequest { @Schema(description = "The input images to be converted to a PDF file") diff --git a/src/main/java/stirling/software/SPDF/model/api/converters/PdfToPresentationRequest.java b/src/main/java/stirling/software/SPDF/model/api/converters/PdfToPresentationRequest.java index f1bf7a9d..0e8b79ad 100644 --- a/src/main/java/stirling/software/SPDF/model/api/converters/PdfToPresentationRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/converters/PdfToPresentationRequest.java @@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.converters; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import org.springframework.web.multipart.MultipartFile; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class PdfToPresentationRequest extends PDFFile { @Schema(description = "The output Presentation format", allowableValues = {"ppt", "pptx", "odp"}) diff --git a/src/main/java/stirling/software/SPDF/model/api/converters/PdfToTextOrRTFRequest.java b/src/main/java/stirling/software/SPDF/model/api/converters/PdfToTextOrRTFRequest.java index 8093cd45..687ed621 100644 --- a/src/main/java/stirling/software/SPDF/model/api/converters/PdfToTextOrRTFRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/converters/PdfToTextOrRTFRequest.java @@ -2,9 +2,11 @@ package stirling.software.SPDF.model.api.converters; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class PdfToTextOrRTFRequest extends PDFFile { @Schema(description = "The output Text or RTF format", allowableValues = {"rtf", "txt:Text"}) diff --git a/src/main/java/stirling/software/SPDF/model/api/converters/PdfToWordRequest.java b/src/main/java/stirling/software/SPDF/model/api/converters/PdfToWordRequest.java index de5a7c4e..87150c73 100644 --- a/src/main/java/stirling/software/SPDF/model/api/converters/PdfToWordRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/converters/PdfToWordRequest.java @@ -2,9 +2,11 @@ package stirling.software.SPDF.model.api.converters; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class PdfToWordRequest extends PDFFile { @Schema(description = "The output Word document format", allowableValues = {"doc", "docx", "odt"}) diff --git a/src/main/java/stirling/software/SPDF/model/api/converters/UrlToPdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/converters/UrlToPdfRequest.java index 7d4e69ed..4607c153 100644 --- a/src/main/java/stirling/software/SPDF/model/api/converters/UrlToPdfRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/converters/UrlToPdfRequest.java @@ -2,8 +2,10 @@ package stirling.software.SPDF.model.api.converters; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode public class UrlToPdfRequest { @Schema(description = "The input URL to be converted to a PDF file", required = true) diff --git a/src/main/java/stirling/software/SPDF/model/api/filter/ContainsTextRequest.java b/src/main/java/stirling/software/SPDF/model/api/filter/ContainsTextRequest.java index 4dc4e137..0b6cb1cb 100644 --- a/src/main/java/stirling/software/SPDF/model/api/filter/ContainsTextRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/filter/ContainsTextRequest.java @@ -2,9 +2,11 @@ package stirling.software.SPDF.model.api.filter; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFWithPageNums; @Data +@EqualsAndHashCode(callSuper=true) public class ContainsTextRequest extends PDFWithPageNums { @Schema(description = "The text to check for", required = true) diff --git a/src/main/java/stirling/software/SPDF/model/api/filter/FileSizeRequest.java b/src/main/java/stirling/software/SPDF/model/api/filter/FileSizeRequest.java index cffcd9a4..ce9a9236 100644 --- a/src/main/java/stirling/software/SPDF/model/api/filter/FileSizeRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/filter/FileSizeRequest.java @@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.filter; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFComparison; -import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class FileSizeRequest extends PDFComparison { @Schema(description = "File Size", required = true) diff --git a/src/main/java/stirling/software/SPDF/model/api/filter/PageRotationRequest.java b/src/main/java/stirling/software/SPDF/model/api/filter/PageRotationRequest.java index 8f36ae5d..d5fb9739 100644 --- a/src/main/java/stirling/software/SPDF/model/api/filter/PageRotationRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/filter/PageRotationRequest.java @@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.filter; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFComparison; -import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class PageRotationRequest extends PDFComparison { @Schema(description = "Rotation in degrees", required = true) diff --git a/src/main/java/stirling/software/SPDF/model/api/filter/PageSizeRequest.java b/src/main/java/stirling/software/SPDF/model/api/filter/PageSizeRequest.java index 0184ac90..12083636 100644 --- a/src/main/java/stirling/software/SPDF/model/api/filter/PageSizeRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/filter/PageSizeRequest.java @@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.filter; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFComparison; -import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class PageSizeRequest extends PDFComparison { @Schema(description = "Standard Page Size", required = true) diff --git a/src/main/java/stirling/software/SPDF/model/api/general/CropPdfForm.java b/src/main/java/stirling/software/SPDF/model/api/general/CropPdfForm.java index 52c0f269..52821515 100644 --- a/src/main/java/stirling/software/SPDF/model/api/general/CropPdfForm.java +++ b/src/main/java/stirling/software/SPDF/model/api/general/CropPdfForm.java @@ -1,13 +1,11 @@ package stirling.software.SPDF.model.api.general; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; -import org.springframework.web.multipart.MultipartFile; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; - @Data +@EqualsAndHashCode(callSuper=true) public class CropPdfForm extends PDFFile { diff --git a/src/main/java/stirling/software/SPDF/model/api/general/MergeMultiplePagesRequest.java b/src/main/java/stirling/software/SPDF/model/api/general/MergeMultiplePagesRequest.java index 6752b1b7..ab6e3510 100644 --- a/src/main/java/stirling/software/SPDF/model/api/general/MergeMultiplePagesRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/general/MergeMultiplePagesRequest.java @@ -2,9 +2,11 @@ package stirling.software.SPDF.model.api.general; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class MergeMultiplePagesRequest extends PDFFile { @Schema(description = "The number of pages to fit onto a single sheet in the output PDF.", diff --git a/src/main/java/stirling/software/SPDF/model/api/general/MergePdfsRequest.java b/src/main/java/stirling/software/SPDF/model/api/general/MergePdfsRequest.java index 4e1ed397..c6d3f98c 100644 --- a/src/main/java/stirling/software/SPDF/model/api/general/MergePdfsRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/general/MergePdfsRequest.java @@ -2,9 +2,11 @@ package stirling.software.SPDF.model.api.general; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.MultiplePDFFiles; @Data +@EqualsAndHashCode(callSuper=true) public class MergePdfsRequest extends MultiplePDFFiles { @Schema(description = "The type of sorting to be applied on the input files before merging.", diff --git a/src/main/java/stirling/software/SPDF/model/api/general/RearrangePagesRequest.java b/src/main/java/stirling/software/SPDF/model/api/general/RearrangePagesRequest.java index 4e054343..3e5b4f23 100644 --- a/src/main/java/stirling/software/SPDF/model/api/general/RearrangePagesRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/general/RearrangePagesRequest.java @@ -2,11 +2,11 @@ package stirling.software.SPDF.model.api.general; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import org.springframework.web.multipart.MultipartFile; -import stirling.software.SPDF.model.api.PDFFile; -import stirling.software.SPDF.model.api.PDFWithPageNums; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.SortTypes; +import stirling.software.SPDF.model.api.PDFWithPageNums; @Data +@EqualsAndHashCode(callSuper=true) public class RearrangePagesRequest extends PDFWithPageNums { @Schema(implementation = SortTypes.class, description = "The custom mode for page rearrangement. Valid values are:\n" diff --git a/src/main/java/stirling/software/SPDF/model/api/general/RotatePDFRequest.java b/src/main/java/stirling/software/SPDF/model/api/general/RotatePDFRequest.java index 58d268a8..8f48c605 100644 --- a/src/main/java/stirling/software/SPDF/model/api/general/RotatePDFRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/general/RotatePDFRequest.java @@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.general; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import org.springframework.web.multipart.MultipartFile; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class RotatePDFRequest extends PDFFile { @Schema(description = "The angle by which to rotate the PDF file. This should be a multiple of 90.", example = "90") diff --git a/src/main/java/stirling/software/SPDF/model/api/general/ScalePagesRequest.java b/src/main/java/stirling/software/SPDF/model/api/general/ScalePagesRequest.java index 3411e1d2..51bdc5fc 100644 --- a/src/main/java/stirling/software/SPDF/model/api/general/ScalePagesRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/general/ScalePagesRequest.java @@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.general; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import org.springframework.web.multipart.MultipartFile; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class ScalePagesRequest extends PDFFile { @Schema(description = "The scale of pages in the output PDF. Acceptable values are A0-A10, B0-B9, LETTER, TABLOID, LEDGER, LEGAL, EXECUTIVE.", diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/AddPageNumbersRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/AddPageNumbersRequest.java index e258b59a..313d42ab 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/AddPageNumbersRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/AddPageNumbersRequest.java @@ -2,11 +2,11 @@ package stirling.software.SPDF.model.api.misc; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFWithPageNums; -import org.springframework.web.multipart.MultipartFile; - @Data +@EqualsAndHashCode(callSuper=true) public class AddPageNumbersRequest extends PDFWithPageNums { @Schema(description = "Custom margin: small/medium/large", allowableValues = {"small", "medium", "large"}) diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/AutoSplitPdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/AutoSplitPdfRequest.java index 822eb7a6..c4923746 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/AutoSplitPdfRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/AutoSplitPdfRequest.java @@ -2,9 +2,11 @@ package stirling.software.SPDF.model.api.misc; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class AutoSplitPdfRequest extends PDFFile { @Schema(description = "Flag indicating if the duplex mode is active, where the page after the divider also gets removed.", required = false, defaultValue = "false") diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/ExtractHeaderRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/ExtractHeaderRequest.java index d05b865e..9dda0d6f 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/ExtractHeaderRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/ExtractHeaderRequest.java @@ -2,9 +2,11 @@ package stirling.software.SPDF.model.api.misc; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class ExtractHeaderRequest extends PDFFile { @Schema(description = "Flag indicating whether to use the first text as a fallback if no suitable title is found. Defaults to false.", required = false, defaultValue = "false") diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/ExtractImageScansRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/ExtractImageScansRequest.java index 8a12fc47..f063e4fc 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/ExtractImageScansRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/ExtractImageScansRequest.java @@ -4,8 +4,10 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode public class ExtractImageScansRequest { @Schema(description = "The input file containing image scans", required = true) private MultipartFile fileInput; diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/MetadataRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/MetadataRequest.java index 586f83f5..0d909613 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/MetadataRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/MetadataRequest.java @@ -1,12 +1,14 @@ package stirling.software.SPDF.model.api.misc; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import stirling.software.SPDF.model.api.PDFFile; - import java.util.Map; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import stirling.software.SPDF.model.api.PDFFile; + @Data +@EqualsAndHashCode(callSuper=true) public class MetadataRequest extends PDFFile { @Schema(description = "Delete all metadata if set to true") diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/OptimizePdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/OptimizePdfRequest.java index 65028a7f..ca43b1eb 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/OptimizePdfRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/OptimizePdfRequest.java @@ -2,9 +2,11 @@ package stirling.software.SPDF.model.api.misc; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class OptimizePdfRequest extends PDFFile { @Schema(description = "The level of optimization to apply to the PDF file. Higher values indicate greater compression but may reduce quality.", diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/OverlayImageRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/OverlayImageRequest.java index 29350519..50ec4abb 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/OverlayImageRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/OverlayImageRequest.java @@ -1,12 +1,14 @@ package stirling.software.SPDF.model.api.misc; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import stirling.software.SPDF.model.api.PDFFile; - import org.springframework.web.multipart.MultipartFile; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import stirling.software.SPDF.model.api.PDFFile; + @Data +@EqualsAndHashCode(callSuper=true) public class OverlayImageRequest extends PDFFile { @Schema(description = "The image file to be overlaid onto the PDF.") diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java index a332a7ff..689e4211 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java @@ -1,13 +1,14 @@ package stirling.software.SPDF.model.api.misc; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.web.multipart.MultipartFile; -import stirling.software.SPDF.model.api.PDFFile; - import java.util.List; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import stirling.software.SPDF.model.api.PDFFile; + @Data +@EqualsAndHashCode(callSuper=true) public class ProcessPdfWithOcrRequest extends PDFFile { @Schema(description = "List of languages to use in OCR processing") diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/RemoveBlankPagesRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/RemoveBlankPagesRequest.java index a7a92897..3f20e2f7 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/RemoveBlankPagesRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/RemoveBlankPagesRequest.java @@ -2,9 +2,11 @@ package stirling.software.SPDF.model.api.misc; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class RemoveBlankPagesRequest extends PDFFile { @Schema(description = "The threshold value to determine blank pages", example = "10", defaultValue = "10") diff --git a/src/main/java/stirling/software/SPDF/model/api/security/AddPasswordRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/AddPasswordRequest.java index 60bbcc6b..06a52d4f 100644 --- a/src/main/java/stirling/software/SPDF/model/api/security/AddPasswordRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/security/AddPasswordRequest.java @@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.security; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import org.springframework.web.multipart.MultipartFile; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class AddPasswordRequest extends PDFFile { @Schema(description = "The owner password to be added to the PDF file (Restricts what can be done with the document once it is opened)", defaultValue = "") diff --git a/src/main/java/stirling/software/SPDF/model/api/security/AddWatermarkRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/AddWatermarkRequest.java index 42d34af4..5fa3f0fb 100644 --- a/src/main/java/stirling/software/SPDF/model/api/security/AddWatermarkRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/security/AddWatermarkRequest.java @@ -1,11 +1,14 @@ package stirling.software.SPDF.model.api.security; +import org.springframework.web.multipart.MultipartFile; + import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import org.springframework.web.multipart.MultipartFile; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class AddWatermarkRequest extends PDFFile { @Schema(description = "The watermark type (text or image)", required = true) diff --git a/src/main/java/stirling/software/SPDF/model/api/security/PDFPasswordRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/PDFPasswordRequest.java index c1acd32c..94d04d1e 100644 --- a/src/main/java/stirling/software/SPDF/model/api/security/PDFPasswordRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/security/PDFPasswordRequest.java @@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.security; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import org.springframework.web.multipart.MultipartFile; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class PDFPasswordRequest extends PDFFile { @Schema(description = "The password of the PDF file", required = true) diff --git a/src/main/java/stirling/software/SPDF/model/api/security/RedactPdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/RedactPdfRequest.java index fff02ff5..1f77bd03 100644 --- a/src/main/java/stirling/software/SPDF/model/api/security/RedactPdfRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/security/RedactPdfRequest.java @@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.security; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import org.springframework.web.multipart.MultipartFile; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class RedactPdfRequest extends PDFFile { @Schema(description = "List of text to redact from the PDF", type = "string", required = true) diff --git a/src/main/java/stirling/software/SPDF/model/api/security/SanitizePdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/SanitizePdfRequest.java index 280f2021..310ee59c 100644 --- a/src/main/java/stirling/software/SPDF/model/api/security/SanitizePdfRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/security/SanitizePdfRequest.java @@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.security; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import org.springframework.web.multipart.MultipartFile; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class SanitizePdfRequest extends PDFFile { @Schema(description = "Remove JavaScript actions from the PDF", defaultValue = "false") diff --git a/src/main/java/stirling/software/SPDF/model/api/security/SignPDFWithCertRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/SignPDFWithCertRequest.java index 5344bf4d..5b2122c6 100644 --- a/src/main/java/stirling/software/SPDF/model/api/security/SignPDFWithCertRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/security/SignPDFWithCertRequest.java @@ -1,11 +1,14 @@ package stirling.software.SPDF.model.api.security; +import org.springframework.web.multipart.MultipartFile; + import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import org.springframework.web.multipart.MultipartFile; +import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; @Data +@EqualsAndHashCode(callSuper=true) public class SignPDFWithCertRequest extends PDFFile { @Schema(description = "The type of the digital certificate", allowableValues = { "PKCS12", "PEM" }) From 0b1fd61188ffbd96e3f2dc7b3dd1b48a4aa97f25 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Mon, 11 Sep 2023 23:19:50 +0100 Subject: [PATCH 06/13] api /api/v1/ --- .../software/SPDF/controller/api/CropController.java | 2 ++ .../SPDF/controller/api/MergeController.java | 2 ++ .../controller/api/MultiPageLayoutController.java | 2 ++ .../controller/api/RearrangePagesPDFController.java | 2 ++ .../SPDF/controller/api/RotationController.java | 2 ++ .../SPDF/controller/api/ScalePagesController.java | 2 ++ .../SPDF/controller/api/SplitPDFController.java | 2 ++ .../SPDF/controller/api/ToSinglePageController.java | 2 ++ .../software/SPDF/controller/api/UserController.java | 2 ++ .../controller/api/converters/ConvertEpubToPdf.java | 2 ++ .../controller/api/converters/ConvertHtmlToPDF.java | 4 +++- .../api/converters/ConvertImgPDFController.java | 6 ++++-- .../api/converters/ConvertMarkdownToPdf.java | 4 +++- .../api/converters/ConvertOfficeController.java | 4 +++- .../api/converters/ConvertPDFToOffice.java | 12 +++++++----- .../controller/api/converters/ConvertPDFToPDFA.java | 4 +++- .../api/converters/ConvertWebsiteToPDF.java | 4 +++- .../controller/api/filters/FilterController.java | 2 ++ .../controller/api/misc/AutoRenameController.java | 4 +++- .../controller/api/misc/AutoSplitPdfController.java | 4 ++++ .../controller/api/misc/BlankPageController.java | 4 +++- .../SPDF/controller/api/misc/CompressController.java | 4 +++- .../api/misc/ExtractImageScansController.java | 4 +++- .../controller/api/misc/ExtractImagesController.java | 4 +++- .../controller/api/misc/FakeScanControllerWIP.java | 4 +++- .../SPDF/controller/api/misc/MetadataController.java | 4 +++- .../SPDF/controller/api/misc/OCRController.java | 4 +++- .../controller/api/misc/OverlayImageController.java | 4 +++- .../controller/api/misc/PageNumbersController.java | 4 +++- .../SPDF/controller/api/misc/RepairController.java | 4 +++- .../SPDF/controller/api/misc/ShowJavascript.java | 4 +++- .../controller/api/pipeline/PipelineController.java | 2 ++ .../controller/api/security/CertSignController.java | 2 ++ .../SPDF/controller/api/security/GetInfoOnPDF.java | 2 ++ .../controller/api/security/PasswordController.java | 2 ++ .../controller/api/security/RedactController.java | 2 ++ .../controller/api/security/SanitizeController.java | 2 ++ .../controller/api/security/WatermarkController.java | 2 ++ src/main/resources/templates/account.html | 8 ++++---- src/main/resources/templates/addUsers.html | 4 ++-- src/main/resources/templates/change-creds.html | 2 +- .../resources/templates/convert/file-to-pdf.html | 2 +- .../resources/templates/convert/html-to-pdf.html | 2 +- src/main/resources/templates/convert/img-to-pdf.html | 2 +- .../resources/templates/convert/markdown-to-pdf.html | 2 +- .../resources/templates/convert/pdf-to-html.html | 2 +- src/main/resources/templates/convert/pdf-to-img.html | 2 +- .../resources/templates/convert/pdf-to-pdfa.html | 2 +- .../templates/convert/pdf-to-presentation.html | 2 +- .../resources/templates/convert/pdf-to-text.html | 2 +- .../resources/templates/convert/pdf-to-word.html | 2 +- src/main/resources/templates/convert/pdf-to-xml.html | 2 +- src/main/resources/templates/convert/url-to-pdf.html | 2 +- src/main/resources/templates/crop.html | 2 +- src/main/resources/templates/extract-page.html | 2 +- src/main/resources/templates/merge-pdfs.html | 2 +- .../templates/{other => misc}/add-image.html | 0 .../templates/{other => misc}/add-page-numbers.html | 2 +- .../templates/{other => misc}/adjust-contrast.html | 0 .../templates/{other => misc}/auto-crop.html | 2 +- .../templates/{other => misc}/auto-rename.html | 2 +- .../templates/{ => misc}/auto-split-pdf.html | 2 +- .../templates/{other => misc}/change-metadata.html | 2 +- .../resources/templates/{other => misc}/compare.html | 0 .../templates/{other => misc}/compress-pdf.html | 2 +- .../{other => misc}/extract-image-scans.html | 2 +- .../templates/{other => misc}/extract-images.html | 2 +- .../resources/templates/{other => misc}/flatten.html | 0 .../templates/{other => misc}/multi-page-layout.html | 2 +- .../resources/templates/{other => misc}/ocr-pdf.html | 2 +- .../templates/{other => misc}/remove-blanks.html | 2 +- .../resources/templates/{other => misc}/repair.html | 2 +- .../templates/{other => misc}/scale-pages.html | 2 +- .../templates/{other => misc}/show-javascript.html | 2 +- src/main/resources/templates/pdf-organizer.html | 2 +- src/main/resources/templates/pdf-to-single-page.html | 2 +- src/main/resources/templates/remove-pages.html | 2 +- src/main/resources/templates/rotate-pdf.html | 2 +- src/main/resources/templates/split-pdfs.html | 2 +- 79 files changed, 143 insertions(+), 65 deletions(-) rename src/main/resources/templates/{other => misc}/add-image.html (100%) rename src/main/resources/templates/{other => misc}/add-page-numbers.html (96%) rename src/main/resources/templates/{other => misc}/adjust-contrast.html (100%) rename src/main/resources/templates/{other => misc}/auto-crop.html (96%) rename src/main/resources/templates/{other => misc}/auto-rename.html (93%) rename src/main/resources/templates/{ => misc}/auto-split-pdf.html (98%) rename src/main/resources/templates/{other => misc}/change-metadata.html (97%) rename src/main/resources/templates/{other => misc}/compare.html (100%) rename src/main/resources/templates/{other => misc}/compress-pdf.html (95%) rename src/main/resources/templates/{other => misc}/extract-image-scans.html (95%) rename src/main/resources/templates/{other => misc}/extract-images.html (91%) rename src/main/resources/templates/{other => misc}/flatten.html (100%) rename src/main/resources/templates/{other => misc}/multi-page-layout.html (91%) rename src/main/resources/templates/{other => misc}/ocr-pdf.html (98%) rename src/main/resources/templates/{other => misc}/remove-blanks.html (93%) rename src/main/resources/templates/{other => misc}/repair.html (89%) rename src/main/resources/templates/{other => misc}/scale-pages.html (96%) rename src/main/resources/templates/{other => misc}/show-javascript.html (98%) diff --git a/src/main/java/stirling/software/SPDF/controller/api/CropController.java b/src/main/java/stirling/software/SPDF/controller/api/CropController.java index 38d68420..8f8deafc 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/CropController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/CropController.java @@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -27,6 +28,7 @@ import stirling.software.SPDF.model.api.general.CropPdfForm; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/general") @Tag(name = "General", description = "General APIs") public class CropController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/MergeController.java b/src/main/java/stirling/software/SPDF/controller/api/MergeController.java index 03bf4066..f256b692 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/MergeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/MergeController.java @@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -31,6 +32,7 @@ import stirling.software.SPDF.model.api.general.MergePdfsRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/general") @Tag(name = "General", description = "General APIs") public class MergeController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java index 12c262cd..4264f844 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java @@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -28,6 +29,7 @@ import stirling.software.SPDF.model.api.general.MergeMultiplePagesRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/general") @Tag(name = "General", description = "General APIs") public class MultiPageLayoutController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java index 294df38d..9530a39b 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -25,6 +26,7 @@ import stirling.software.SPDF.utils.WebResponseUtils; import stirling.software.SPDF.model.SortTypes; import stirling.software.SPDF.model.api.general.RearrangePagesRequest; @RestController +@RequestMapping("/api/v1/general") @Tag(name = "General", description = "General APIs") public class RearrangePagesPDFController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/RotationController.java b/src/main/java/stirling/software/SPDF/controller/api/RotationController.java index ef32df4e..be3fcbff 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RotationController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RotationController.java @@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -22,6 +23,7 @@ import stirling.software.SPDF.model.api.general.RotatePDFRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/general") @Tag(name = "General", description = "General APIs") public class RotationController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java index 2dcb26af..4e155d1d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java @@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -28,6 +29,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.general.ScalePagesRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/general") @Tag(name = "General", description = "General APIs") public class ScalePagesController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java index fe3a1cc5..6ddf42f4 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java @@ -19,6 +19,7 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -32,6 +33,7 @@ import stirling.software.SPDF.utils.GeneralUtils; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/general") @Tag(name = "General", description = "General APIs") public class SplitPDFController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java b/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java index ea64d55b..28697531 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java @@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -25,6 +26,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/general") @Tag(name = "General", description = "General APIs") public class ToSinglePageController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/UserController.java b/src/main/java/stirling/software/SPDF/controller/api/UserController.java index bd4452da..bf451567 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/UserController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/UserController.java @@ -15,6 +15,7 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.view.RedirectView; @@ -25,6 +26,7 @@ import stirling.software.SPDF.config.security.UserService; import stirling.software.SPDF.model.User; @Controller +@RequestMapping("/api/v1/user") public class UserController { @Autowired diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java index 77262cce..8fd9d809 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java @@ -16,6 +16,7 @@ import javax.xml.parsers.DocumentBuilderFactory; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -33,6 +34,7 @@ import stirling.software.SPDF.utils.FileToPdf; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/convert") @Tag(name = "Convert", description = "Convert APIs") public class ConvertEpubToPdf { //TODO diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java index d9308d09..f6a2036b 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java @@ -5,6 +5,7 @@ import java.io.IOException; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -17,10 +18,11 @@ import stirling.software.SPDF.utils.WebResponseUtils; @RestController @Tag(name = "Convert", description = "Convert APIs") +@RequestMapping("/api/v1/convert") public class ConvertHtmlToPDF { - @PostMapping(consumes = "multipart/form-data", value = "/html-to-pdf") + @PostMapping(consumes = "multipart/form-data", value = "/html/pdf") @Operation( summary = "Convert an HTML or ZIP (containing HTML and CSS) to PDF", description = "This endpoint takes an HTML or ZIP file input and converts it to a PDF format." diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java index 5a4dab2c..e65d1f3c 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java @@ -13,6 +13,7 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -27,12 +28,13 @@ import stirling.software.SPDF.model.api.converters.ConvertToPdfRequest; import stirling.software.SPDF.utils.PdfUtils; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/convert") @Tag(name = "Convert", description = "Convert APIs") public class ConvertImgPDFController { private static final Logger logger = LoggerFactory.getLogger(ConvertImgPDFController.class); - @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-img") + @PostMapping(consumes = "multipart/form-data", value = "/pdf/img") @Operation(summary = "Convert PDF to image(s)", description = "This endpoint converts a PDF file to image(s) with the specified image format, color type, and DPI. Users can choose to get a single image or multiple images. Input:PDF Output:Image Type:SI-Conditional") public ResponseEntity convertToImage(@ModelAttribute ConvertToImageRequest request) throws IOException { @@ -76,7 +78,7 @@ public class ConvertImgPDFController { } } - @PostMapping(consumes = "multipart/form-data", value = "/img-to-pdf") + @PostMapping(consumes = "multipart/form-data", value = "/img/pdf") @Operation(summary = "Convert images to a PDF file", description = "This endpoint converts one or more images to a PDF file. Users can specify whether to stretch the images to fit the PDF page, and whether to automatically rotate the images. Input:Image Output:PDF Type:SISO?") public ResponseEntity convertToPdf(@ModelAttribute ConvertToPdfRequest request) throws IOException { diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java index 02ff1e27..4726562f 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java @@ -8,6 +8,7 @@ import org.commonmark.renderer.html.HtmlRenderer; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -20,9 +21,10 @@ import stirling.software.SPDF.utils.WebResponseUtils; @RestController @Tag(name = "Convert", description = "Convert APIs") +@RequestMapping("/api/v1/convert") public class ConvertMarkdownToPdf { - @PostMapping(consumes = "multipart/form-data", value = "/markdown-to-pdf") + @PostMapping(consumes = "multipart/form-data", value = "/markdown/pdf") @Operation( summary = "Convert a Markdown file to PDF", description = "This endpoint takes a Markdown file input, converts it to HTML, and then to PDF format." diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java index 9ee5cdd5..f5f5bc27 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java @@ -12,6 +12,7 @@ import org.apache.commons.io.FilenameUtils; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -26,6 +27,7 @@ import stirling.software.SPDF.utils.WebResponseUtils; @RestController @Tag(name = "Convert", description = "Convert APIs") +@RequestMapping("/api/v1/convert") public class ConvertOfficeController { public byte[] convertToPdf(MultipartFile inputFile) throws IOException, InterruptedException { @@ -60,7 +62,7 @@ public class ConvertOfficeController { return fileExtension.matches(extensionPattern); } - @PostMapping(consumes = "multipart/form-data", value = "/file-to-pdf") + @PostMapping(consumes = "multipart/form-data", value = "/file/pdf") @Operation( summary = "Convert a file to a PDF using LibreOffice", description = "This endpoint converts a given file to a PDF using LibreOffice API Input:Any Output:PDF Type:SISO" diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java index b61549ff..52ac5a8d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java @@ -5,6 +5,7 @@ import java.io.IOException; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -22,10 +23,11 @@ import stirling.software.SPDF.model.api.converters.PdfToWordRequest; import stirling.software.SPDF.utils.PDFToFile; @RestController +@RequestMapping("/api/v1/convert") @Tag(name = "Convert", description = "Convert APIs") public class ConvertPDFToOffice { - @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-html") + @PostMapping(consumes = "multipart/form-data", value = "/pdf/html") @Operation(summary = "Convert PDF to HTML", description = "This endpoint converts a PDF file to HTML format. Input:PDF Output:HTML Type:SISO") public ResponseEntity processPdfToHTML(@ModelAttribute PDFFile request) throws Exception { @@ -34,7 +36,7 @@ public class ConvertPDFToOffice { return pdfToFile.processPdfToOfficeFormat(inputFile, "html", "writer_pdf_import"); } - @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-presentation") + @PostMapping(consumes = "multipart/form-data", value = "/pdf/presentation") @Operation(summary = "Convert PDF to Presentation format", description = "This endpoint converts a given PDF file to a Presentation format. Input:PDF Output:PPT Type:SISO") public ResponseEntity processPdfToPresentation(@ModelAttribute PdfToPresentationRequest request) throws IOException, InterruptedException { MultipartFile inputFile = request.getFileInput(); @@ -43,7 +45,7 @@ public class ConvertPDFToOffice { return pdfToFile.processPdfToOfficeFormat(inputFile, outputFormat, "impress_pdf_import"); } - @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-text") + @PostMapping(consumes = "multipart/form-data", value = "/pdf/text") @Operation(summary = "Convert PDF to Text or RTF format", description = "This endpoint converts a given PDF file to Text or RTF format. Input:PDF Output:TXT Type:SISO") public ResponseEntity processPdfToRTForTXT(@ModelAttribute PdfToTextOrRTFRequest request) throws IOException, InterruptedException { MultipartFile inputFile = request.getFileInput(); @@ -53,7 +55,7 @@ public class ConvertPDFToOffice { return pdfToFile.processPdfToOfficeFormat(inputFile, outputFormat, "writer_pdf_import"); } - @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-word") + @PostMapping(consumes = "multipart/form-data", value = "/pdf/word") @Operation(summary = "Convert PDF to Word document", description = "This endpoint converts a given PDF file to a Word document format. Input:PDF Output:WORD Type:SISO") public ResponseEntity processPdfToWord(@ModelAttribute PdfToWordRequest request) throws IOException, InterruptedException { MultipartFile inputFile = request.getFileInput(); @@ -62,7 +64,7 @@ public class ConvertPDFToOffice { return pdfToFile.processPdfToOfficeFormat(inputFile, outputFormat, "writer_pdf_import"); } - @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-xml") + @PostMapping(consumes = "multipart/form-data", value = "/pdf/xml") @Operation(summary = "Convert PDF to XML", description = "This endpoint converts a PDF file to an XML file. Input:PDF Output:XML Type:SISO") public ResponseEntity processPdfToXML(@ModelAttribute PDFFile request) throws Exception { diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java index ca83d4ed..90f4f06d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java @@ -9,6 +9,7 @@ import java.util.List; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -22,10 +23,11 @@ import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/convert") @Tag(name = "Convert", description = "Convert APIs") public class ConvertPDFToPDFA { - @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-pdfa") + @PostMapping(consumes = "multipart/form-data", value = "/pdf/pdfa") @Operation( summary = "Convert a PDF to a PDF/A", description = "This endpoint converts a PDF file to a PDF/A file. PDF/A is a format designed for long-term archiving of digital documents. Input:PDF Output:PDF Type:SISO" diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java index 3d4fd368..580fe3a5 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java @@ -9,6 +9,7 @@ import java.util.List; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -23,9 +24,10 @@ import stirling.software.SPDF.utils.WebResponseUtils; @RestController @Tag(name = "Convert", description = "Convert APIs") +@RequestMapping("/api/v1/convert") public class ConvertWebsiteToPDF { - @PostMapping(consumes = "multipart/form-data", value = "/url-to-pdf") + @PostMapping(consumes = "multipart/form-data", value = "/url/pdf") @Operation( summary = "Convert a URL to a PDF", description = "This endpoint fetches content from a URL and converts it to a PDF format." diff --git a/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java b/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java index dbb20bfe..8218da33 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java @@ -8,6 +8,7 @@ import org.apache.pdfbox.pdmodel.common.PDRectangle; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -26,6 +27,7 @@ import stirling.software.SPDF.utils.PdfUtils; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/filter") @Tag(name = "Filter", description = "Filter APIs") public class FilterController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java index 8059062c..d26b0fee 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java @@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -24,7 +25,8 @@ import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.ExtractHeaderRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController -@Tag(name = "Other", description = "Other APIs") +@RequestMapping("/api/v1/misc") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class AutoRenameController { private static final Logger logger = LoggerFactory.getLogger(AutoRenameController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java index 3ba81f78..821fbec1 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java @@ -18,6 +18,7 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -32,10 +33,13 @@ import com.google.zxing.common.HybridBinarizer; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.AutoSplitPdfRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/misc") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class AutoSplitPdfController { private static final String QR_CONTENT = "https://github.com/Frooodle/Stirling-PDF"; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java index 5107d8c0..afad69e3 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java @@ -22,6 +22,7 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -37,7 +38,8 @@ import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; @RestController -@Tag(name = "Other", description = "Other APIs") +@RequestMapping("/api/v1/misc") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class BlankPageController { @PostMapping(consumes = "multipart/form-data", value = "/remove-blanks") diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java index 89147056..d8fdb0d4 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java @@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -40,7 +41,8 @@ import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; @RestController -@Tag(name = "Other", description = "Other APIs") +@RequestMapping("/api/v1/misc") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class CompressController { private static final Logger logger = LoggerFactory.getLogger(CompressController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java index 5a1bbf8a..c725ea1a 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java @@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -40,7 +41,8 @@ import stirling.software.SPDF.utils.WebResponseUtils; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; @RestController -@Tag(name = "Other", description = "Other APIs") +@RequestMapping("/api/v1/misc") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class ExtractImageScansController { private static final Logger logger = LoggerFactory.getLogger(ExtractImageScansController.class); 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 91bbff09..6546363c 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 @@ -22,6 +22,7 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -34,7 +35,8 @@ import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFWithImageFormatRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController -@Tag(name = "Other", description = "Other APIs") +@RequestMapping("/api/v1/misc") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class ExtractImagesController { private static final Logger logger = LoggerFactory.getLogger(ExtractImagesController.class); 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 70fc2e88..21b3d4e2 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 @@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -44,7 +45,8 @@ import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; @RestController -@Tag(name = "Other", description = "Other APIs") +@RequestMapping("/api/v1/misc") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class FakeScanControllerWIP { private static final Logger logger = LoggerFactory.getLogger(FakeScanControllerWIP.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java index aa9b5395..836e2200 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java @@ -13,6 +13,7 @@ import org.apache.pdfbox.pdmodel.PDDocumentInformation; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -25,7 +26,8 @@ import stirling.software.SPDF.model.api.misc.MetadataRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController -@Tag(name = "Other", description = "Other APIs") +@RequestMapping("/api/v1/misc") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class MetadataController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java index aa25b9b4..bc0e7938 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java @@ -20,6 +20,7 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -35,7 +36,8 @@ import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; @RestController -@Tag(name = "Other", description = "Other APIs") +@RequestMapping("/api/v1/misc") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class OCRController { private static final Logger logger = LoggerFactory.getLogger(OCRController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java index 44c16fd7..5cf6af8d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java @@ -8,6 +8,7 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -21,7 +22,8 @@ import stirling.software.SPDF.utils.PdfUtils; import stirling.software.SPDF.utils.WebResponseUtils; @RestController -@Tag(name = "Other", description = "Other APIs") +@RequestMapping("/api/v1/misc") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class OverlayImageController { private static final Logger logger = LoggerFactory.getLogger(OverlayImageController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java index d1ecc9df..e7f7f4cb 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java @@ -15,6 +15,7 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -28,7 +29,8 @@ import stirling.software.SPDF.utils.GeneralUtils; import stirling.software.SPDF.utils.WebResponseUtils; @RestController -@Tag(name = "Other", description = "Other APIs") +@RequestMapping("/api/v1/misc") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class PageNumbersController { private static final Logger logger = LoggerFactory.getLogger(PageNumbersController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java index 819f8f70..1a0b73b5 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -25,7 +26,8 @@ import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; @RestController -@Tag(name = "Other", description = "Other APIs") +@RequestMapping("/api/v1/misc") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class RepairController { private static final Logger logger = LoggerFactory.getLogger(RepairController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java index d3101ff2..8295f034 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -19,7 +20,8 @@ import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; @RestController -@Tag(name = "Other", description = "Other APIs") +@RequestMapping("/api/v1/misc") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class ShowJavascript { private static final Logger logger = LoggerFactory.getLogger(ShowJavascript.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java b/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java index 0e5d8de3..5a3f1389 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java @@ -39,6 +39,7 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -56,6 +57,7 @@ import stirling.software.SPDF.model.api.HandleDataRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/pipeline") @Tag(name = "Pipeline", description = "Pipeline APIs") public class PipelineController { 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 d9eb68a3..9e17f2fe 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 @@ -46,6 +46,7 @@ import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -59,6 +60,7 @@ import stirling.software.SPDF.model.api.security.SignPDFWithCertRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/security") @Tag(name = "Security", description = "Security APIs") public class CertSignController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java b/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java index 48f1c655..638d7cf6 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java @@ -62,6 +62,7 @@ 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -76,6 +77,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/security") @Tag(name = "Security", description = "Security APIs") public class GetInfoOnPDF { diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java index 9634143b..8bec2e82 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java @@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -23,6 +24,7 @@ import stirling.software.SPDF.model.api.security.AddPasswordRequest; import stirling.software.SPDF.model.api.security.PDFPasswordRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/security") @Tag(name = "Security", description = "Security APIs") public class PasswordController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java b/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java index 6c0a5526..d66e3003 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java @@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -33,6 +34,7 @@ import stirling.software.SPDF.model.api.security.RedactPdfRequest; import stirling.software.SPDF.pdf.TextFinder; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/security") @Tag(name = "Security", description = "Security APIs") public class RedactController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java index ccf088de..d867cf1d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java @@ -22,6 +22,7 @@ import org.apache.pdfbox.pdmodel.interactive.form.PDField; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -33,6 +34,7 @@ import stirling.software.SPDF.model.api.security.SanitizePdfRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/security") public class SanitizeController { @PostMapping(consumes = "multipart/form-data", value = "/sanitize-pdf") diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java index a46f4ff4..eee30119 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java @@ -24,6 +24,7 @@ import org.springframework.core.io.ClassPathResource; 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.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -37,6 +38,7 @@ import stirling.software.SPDF.model.api.security.AddWatermarkRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@RequestMapping("/api/v1/security") @Tag(name = "Security", description = "Security APIs") public class WatermarkController { diff --git a/src/main/resources/templates/account.html b/src/main/resources/templates/account.html index 4a7a3174..b7beed7f 100644 --- a/src/main/resources/templates/account.html +++ b/src/main/resources/templates/account.html @@ -42,7 +42,7 @@

-
+
@@ -60,7 +60,7 @@

Change Password?

- +
@@ -129,7 +129,7 @@ document.addEventListener("DOMContentLoaded", async function() { try { - let response = await fetch('/get-api-key', { method: 'POST' }); + let response = await fetch('/api/v1/user/get-api-key', { method: 'POST' }); if (response.status === 200) { let apiKey = await response.text(); manageUIState(apiKey); @@ -143,7 +143,7 @@ async function refreshApiKey() { try { - let response = await fetch('/update-api-key', { method: 'POST' }); + let response = await fetch('/api/v1/user/update-api-key', { method: 'POST' }); if (response.status === 200) { let apiKey = await response.text(); manageUIState(apiKey); diff --git a/src/main/resources/templates/addUsers.html b/src/main/resources/templates/addUsers.html index 094ede17..4ab59a8b 100644 --- a/src/main/resources/templates/addUsers.html +++ b/src/main/resources/templates/addUsers.html @@ -32,7 +32,7 @@ - + @@ -46,7 +46,7 @@
Default message if not found
-
+
diff --git a/src/main/resources/templates/change-creds.html b/src/main/resources/templates/change-creds.html index 6e19bcef..5c62fe1d 100644 --- a/src/main/resources/templates/change-creds.html +++ b/src/main/resources/templates/change-creds.html @@ -37,7 +37,7 @@

Change Username and password

- +
diff --git a/src/main/resources/templates/convert/file-to-pdf.html b/src/main/resources/templates/convert/file-to-pdf.html index f90572f0..fe56c164 100644 --- a/src/main/resources/templates/convert/file-to-pdf.html +++ b/src/main/resources/templates/convert/file-to-pdf.html @@ -15,7 +15,7 @@

- +


diff --git a/src/main/resources/templates/convert/html-to-pdf.html b/src/main/resources/templates/convert/html-to-pdf.html index 7a384d19..546ef1fc 100644 --- a/src/main/resources/templates/convert/html-to-pdf.html +++ b/src/main/resources/templates/convert/html-to-pdf.html @@ -12,7 +12,7 @@

- +

diff --git a/src/main/resources/templates/convert/img-to-pdf.html b/src/main/resources/templates/convert/img-to-pdf.html index 78da1934..c6a2d037 100644 --- a/src/main/resources/templates/convert/img-to-pdf.html +++ b/src/main/resources/templates/convert/img-to-pdf.html @@ -15,7 +15,7 @@

- + diff --git a/src/main/resources/templates/convert/markdown-to-pdf.html b/src/main/resources/templates/convert/markdown-to-pdf.html index 4637d129..7b8be463 100644 --- a/src/main/resources/templates/convert/markdown-to-pdf.html +++ b/src/main/resources/templates/convert/markdown-to-pdf.html @@ -12,7 +12,7 @@

- +

diff --git a/src/main/resources/templates/convert/pdf-to-html.html b/src/main/resources/templates/convert/pdf-to-html.html index 4e28471c..671ff034 100644 --- a/src/main/resources/templates/convert/pdf-to-html.html +++ b/src/main/resources/templates/convert/pdf-to-html.html @@ -12,7 +12,7 @@

- +

diff --git a/src/main/resources/templates/convert/pdf-to-img.html b/src/main/resources/templates/convert/pdf-to-img.html index 443334f4..1d6db966 100644 --- a/src/main/resources/templates/convert/pdf-to-img.html +++ b/src/main/resources/templates/convert/pdf-to-img.html @@ -16,7 +16,7 @@

- +
diff --git a/src/main/resources/templates/convert/pdf-to-pdfa.html b/src/main/resources/templates/convert/pdf-to-pdfa.html index 6a5a17c6..dfddb792 100644 --- a/src/main/resources/templates/convert/pdf-to-pdfa.html +++ b/src/main/resources/templates/convert/pdf-to-pdfa.html @@ -15,7 +15,7 @@

Currently doesn't work for multiple inputs at once

- +

diff --git a/src/main/resources/templates/convert/pdf-to-presentation.html b/src/main/resources/templates/convert/pdf-to-presentation.html index 4c784017..51a0440b 100644 --- a/src/main/resources/templates/convert/pdf-to-presentation.html +++ b/src/main/resources/templates/convert/pdf-to-presentation.html @@ -12,7 +12,7 @@

- +
diff --git a/src/main/resources/templates/convert/pdf-to-text.html b/src/main/resources/templates/convert/pdf-to-text.html index a31dad74..0f479178 100644 --- a/src/main/resources/templates/convert/pdf-to-text.html +++ b/src/main/resources/templates/convert/pdf-to-text.html @@ -12,7 +12,7 @@

- +
diff --git a/src/main/resources/templates/convert/pdf-to-word.html b/src/main/resources/templates/convert/pdf-to-word.html index a10ca12f..d2531084 100644 --- a/src/main/resources/templates/convert/pdf-to-word.html +++ b/src/main/resources/templates/convert/pdf-to-word.html @@ -12,7 +12,7 @@

- +
diff --git a/src/main/resources/templates/convert/pdf-to-xml.html b/src/main/resources/templates/convert/pdf-to-xml.html index 4aecbc66..d32ba5dc 100644 --- a/src/main/resources/templates/convert/pdf-to-xml.html +++ b/src/main/resources/templates/convert/pdf-to-xml.html @@ -12,7 +12,7 @@

- +

diff --git a/src/main/resources/templates/convert/url-to-pdf.html b/src/main/resources/templates/convert/url-to-pdf.html index fb59b4ba..09a0d35a 100644 --- a/src/main/resources/templates/convert/url-to-pdf.html +++ b/src/main/resources/templates/convert/url-to-pdf.html @@ -12,7 +12,7 @@

- +
diff --git a/src/main/resources/templates/crop.html b/src/main/resources/templates/crop.html index 911a8f32..b0347477 100644 --- a/src/main/resources/templates/crop.html +++ b/src/main/resources/templates/crop.html @@ -13,7 +13,7 @@

- +
diff --git a/src/main/resources/templates/extract-page.html b/src/main/resources/templates/extract-page.html index 06900be2..a243461e 100644 --- a/src/main/resources/templates/extract-page.html +++ b/src/main/resources/templates/extract-page.html @@ -13,7 +13,7 @@

- +
diff --git a/src/main/resources/templates/merge-pdfs.html b/src/main/resources/templates/merge-pdfs.html index efd5949b..05982d26 100644 --- a/src/main/resources/templates/merge-pdfs.html +++ b/src/main/resources/templates/merge-pdfs.html @@ -13,7 +13,7 @@

- +
diff --git a/src/main/resources/templates/other/add-image.html b/src/main/resources/templates/misc/add-image.html similarity index 100% rename from src/main/resources/templates/other/add-image.html rename to src/main/resources/templates/misc/add-image.html diff --git a/src/main/resources/templates/other/add-page-numbers.html b/src/main/resources/templates/misc/add-page-numbers.html similarity index 96% rename from src/main/resources/templates/other/add-page-numbers.html rename to src/main/resources/templates/misc/add-page-numbers.html index c7bc5514..1ede15f8 100644 --- a/src/main/resources/templates/other/add-page-numbers.html +++ b/src/main/resources/templates/misc/add-page-numbers.html @@ -18,7 +18,7 @@

+ th:action="@{api/v1/misc/add-page-numbers}">

diff --git a/src/main/resources/templates/other/adjust-contrast.html b/src/main/resources/templates/misc/adjust-contrast.html similarity index 100% rename from src/main/resources/templates/other/adjust-contrast.html rename to src/main/resources/templates/misc/adjust-contrast.html diff --git a/src/main/resources/templates/other/auto-crop.html b/src/main/resources/templates/misc/auto-crop.html similarity index 96% rename from src/main/resources/templates/other/auto-crop.html rename to src/main/resources/templates/misc/auto-crop.html index a7ba407a..d3a8970f 100644 --- a/src/main/resources/templates/other/auto-crop.html +++ b/src/main/resources/templates/misc/auto-crop.html @@ -14,7 +14,7 @@

- +

diff --git a/src/main/resources/templates/other/auto-rename.html b/src/main/resources/templates/misc/auto-rename.html similarity index 93% rename from src/main/resources/templates/other/auto-rename.html rename to src/main/resources/templates/misc/auto-rename.html index 5f3b9dba..137c4290 100644 --- a/src/main/resources/templates/other/auto-rename.html +++ b/src/main/resources/templates/misc/auto-rename.html @@ -14,7 +14,7 @@

- +

diff --git a/src/main/resources/templates/auto-split-pdf.html b/src/main/resources/templates/misc/auto-split-pdf.html similarity index 98% rename from src/main/resources/templates/auto-split-pdf.html rename to src/main/resources/templates/misc/auto-split-pdf.html index cd2596e5..4cc39c99 100644 --- a/src/main/resources/templates/auto-split-pdf.html +++ b/src/main/resources/templates/misc/auto-split-pdf.html @@ -22,7 +22,7 @@
  • - +

    diff --git a/src/main/resources/templates/other/change-metadata.html b/src/main/resources/templates/misc/change-metadata.html similarity index 97% rename from src/main/resources/templates/other/change-metadata.html rename to src/main/resources/templates/misc/change-metadata.html index e341c1eb..68e4fa1c 100644 --- a/src/main/resources/templates/other/change-metadata.html +++ b/src/main/resources/templates/misc/change-metadata.html @@ -13,7 +13,7 @@

    - +

    diff --git a/src/main/resources/templates/other/compare.html b/src/main/resources/templates/misc/compare.html similarity index 100% rename from src/main/resources/templates/other/compare.html rename to src/main/resources/templates/misc/compare.html diff --git a/src/main/resources/templates/other/compress-pdf.html b/src/main/resources/templates/misc/compress-pdf.html similarity index 95% rename from src/main/resources/templates/other/compress-pdf.html rename to src/main/resources/templates/misc/compress-pdf.html index 99612271..ab8e3964 100644 --- a/src/main/resources/templates/other/compress-pdf.html +++ b/src/main/resources/templates/misc/compress-pdf.html @@ -15,7 +15,7 @@

    - +
    diff --git a/src/main/resources/templates/other/extract-image-scans.html b/src/main/resources/templates/misc/extract-image-scans.html similarity index 95% rename from src/main/resources/templates/other/extract-image-scans.html rename to src/main/resources/templates/misc/extract-image-scans.html index 80a2d7fb..42a0544b 100644 --- a/src/main/resources/templates/other/extract-image-scans.html +++ b/src/main/resources/templates/misc/extract-image-scans.html @@ -14,7 +14,7 @@

    - +
    diff --git a/src/main/resources/templates/other/extract-images.html b/src/main/resources/templates/misc/extract-images.html similarity index 91% rename from src/main/resources/templates/other/extract-images.html rename to src/main/resources/templates/misc/extract-images.html index 66a35036..f3f1d4a5 100644 --- a/src/main/resources/templates/other/extract-images.html +++ b/src/main/resources/templates/misc/extract-images.html @@ -14,7 +14,7 @@

    - +
    diff --git a/src/main/resources/templates/other/flatten.html b/src/main/resources/templates/misc/flatten.html similarity index 100% rename from src/main/resources/templates/other/flatten.html rename to src/main/resources/templates/misc/flatten.html diff --git a/src/main/resources/templates/other/multi-page-layout.html b/src/main/resources/templates/misc/multi-page-layout.html similarity index 91% rename from src/main/resources/templates/other/multi-page-layout.html rename to src/main/resources/templates/misc/multi-page-layout.html index a0fc2615..9f2f5373 100644 --- a/src/main/resources/templates/other/multi-page-layout.html +++ b/src/main/resources/templates/misc/multi-page-layout.html @@ -14,7 +14,7 @@

    - +
    diff --git a/src/main/resources/templates/other/ocr-pdf.html b/src/main/resources/templates/misc/ocr-pdf.html similarity index 98% rename from src/main/resources/templates/other/ocr-pdf.html rename to src/main/resources/templates/misc/ocr-pdf.html index 52836b9e..8b9dc454 100644 --- a/src/main/resources/templates/other/ocr-pdf.html +++ b/src/main/resources/templates/misc/ocr-pdf.html @@ -38,7 +38,7 @@

    - +
    diff --git a/src/main/resources/templates/other/remove-blanks.html b/src/main/resources/templates/misc/remove-blanks.html similarity index 93% rename from src/main/resources/templates/other/remove-blanks.html rename to src/main/resources/templates/misc/remove-blanks.html index a464754f..a4d017ec 100644 --- a/src/main/resources/templates/other/remove-blanks.html +++ b/src/main/resources/templates/misc/remove-blanks.html @@ -14,7 +14,7 @@

    - +
    diff --git a/src/main/resources/templates/other/repair.html b/src/main/resources/templates/misc/repair.html similarity index 89% rename from src/main/resources/templates/other/repair.html rename to src/main/resources/templates/misc/repair.html index 8ce329b6..c8ecef40 100644 --- a/src/main/resources/templates/other/repair.html +++ b/src/main/resources/templates/misc/repair.html @@ -14,7 +14,7 @@

    - +
    diff --git a/src/main/resources/templates/other/scale-pages.html b/src/main/resources/templates/misc/scale-pages.html similarity index 96% rename from src/main/resources/templates/other/scale-pages.html rename to src/main/resources/templates/misc/scale-pages.html index c0c4f78e..c252b9e1 100644 --- a/src/main/resources/templates/other/scale-pages.html +++ b/src/main/resources/templates/misc/scale-pages.html @@ -14,7 +14,7 @@

    -
    +
    diff --git a/src/main/resources/templates/other/show-javascript.html b/src/main/resources/templates/misc/show-javascript.html similarity index 98% rename from src/main/resources/templates/other/show-javascript.html rename to src/main/resources/templates/misc/show-javascript.html index ef9e014e..eab3e99b 100644 --- a/src/main/resources/templates/other/show-javascript.html +++ b/src/main/resources/templates/misc/show-javascript.html @@ -49,7 +49,7 @@ // Fetch the formData const formData = new FormData(event.target); - fetch('show-javascript', { + fetch('api/v1/misc/show-javascript', { method: 'POST', body: formData }).then(response => response.text()) diff --git a/src/main/resources/templates/pdf-organizer.html b/src/main/resources/templates/pdf-organizer.html index c6e1508f..696245cb 100644 --- a/src/main/resources/templates/pdf-organizer.html +++ b/src/main/resources/templates/pdf-organizer.html @@ -14,7 +14,7 @@

    - +
    diff --git a/src/main/resources/templates/pdf-to-single-page.html b/src/main/resources/templates/pdf-to-single-page.html index 75007224..e95a5d43 100644 --- a/src/main/resources/templates/pdf-to-single-page.html +++ b/src/main/resources/templates/pdf-to-single-page.html @@ -13,7 +13,7 @@

    - +
    diff --git a/src/main/resources/templates/remove-pages.html b/src/main/resources/templates/remove-pages.html index 271158f9..749a1c2f 100644 --- a/src/main/resources/templates/remove-pages.html +++ b/src/main/resources/templates/remove-pages.html @@ -14,7 +14,7 @@

    -
    +
    diff --git a/src/main/resources/templates/rotate-pdf.html b/src/main/resources/templates/rotate-pdf.html index 9485efc8..edf93d70 100644 --- a/src/main/resources/templates/rotate-pdf.html +++ b/src/main/resources/templates/rotate-pdf.html @@ -15,7 +15,7 @@

    - +
    diff --git a/src/main/resources/templates/split-pdfs.html b/src/main/resources/templates/split-pdfs.html index 718f5cd4..a8a59e02 100644 --- a/src/main/resources/templates/split-pdfs.html +++ b/src/main/resources/templates/split-pdfs.html @@ -23,7 +23,7 @@

    - +
    From 24e665bfd51ec22aebdafa829b1a4793a5063a95 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Mon, 11 Sep 2023 23:42:18 +0100 Subject: [PATCH 07/13] cleanup and defaults --- .../software/SPDF/controller/api/CropController.java | 4 ---- .../software/SPDF/controller/api/MergeController.java | 5 ----- .../SPDF/controller/api/MultiPageLayoutController.java | 3 --- .../SPDF/controller/api/RotationController.java | 3 --- .../SPDF/controller/api/ScalePagesController.java | 3 --- .../SPDF/controller/api/SplitPDFController.java | 4 ---- .../SPDF/controller/api/ToSinglePageController.java | 3 --- .../controller/api/converters/ConvertEpubToPdf.java | 2 -- .../controller/api/converters/ConvertHtmlToPDF.java | 3 --- .../api/converters/ConvertImgPDFController.java | 4 ---- .../api/converters/ConvertMarkdownToPdf.java | 3 --- .../api/converters/ConvertOfficeController.java | 2 -- .../controller/api/converters/ConvertPDFToOffice.java | 5 ----- .../controller/api/converters/ConvertPDFToPDFA.java | 3 --- .../controller/api/converters/ConvertWebsiteToPDF.java | 2 -- .../SPDF/controller/api/filters/FilterController.java | 3 --- .../SPDF/controller/api/misc/AutoRenameController.java | 3 --- .../controller/api/misc/AutoSplitPdfController.java | 2 -- .../SPDF/controller/api/misc/BlankPageController.java | 3 --- .../SPDF/controller/api/misc/CompressController.java | 4 ---- .../api/misc/ExtractImageScansController.java | 8 ++------ .../controller/api/misc/ExtractImagesController.java | 4 ---- .../controller/api/misc/FakeScanControllerWIP.java | 2 -- .../SPDF/controller/api/misc/MetadataController.java | 3 --- .../SPDF/controller/api/misc/OCRController.java | 4 ---- .../controller/api/misc/OverlayImageController.java | 3 --- .../controller/api/misc/PageNumbersController.java | 3 --- .../SPDF/controller/api/misc/RepairController.java | 3 --- .../SPDF/controller/api/misc/ShowJavascript.java | 1 - .../controller/api/pipeline/PipelineController.java | 2 -- .../controller/api/security/CertSignController.java | 4 ---- .../SPDF/controller/api/security/GetInfoOnPDF.java | 2 -- .../controller/api/security/PasswordController.java | 4 ---- .../SPDF/controller/api/security/RedactController.java | 3 --- .../controller/api/security/SanitizeController.java | 3 --- .../controller/api/security/WatermarkController.java | 4 ---- .../SPDF/model/api/general/MergePdfsRequest.java | 2 +- .../SPDF/model/api/misc/ExtractImageScansRequest.java | 10 +++++----- .../SPDF/model/api/misc/ProcessPdfWithOcrRequest.java | 2 +- .../SPDF/model/api/misc/RemoveBlankPagesRequest.java | 4 ++-- .../SPDF/model/api/security/AddPasswordRequest.java | 2 +- .../SPDF/model/api/security/AddWatermarkRequest.java | 10 ++++++---- .../SPDF/model/api/security/RedactPdfRequest.java | 2 +- .../resources/templates/security/add-password.html | 2 +- .../resources/templates/security/add-watermark.html | 2 +- src/main/resources/templates/security/auto-redact.html | 2 +- src/main/resources/templates/security/cert-sign.html | 2 +- .../templates/security/change-permissions.html | 2 +- .../resources/templates/security/get-info-on-pdf.html | 2 +- .../resources/templates/security/remove-password.html | 2 +- .../resources/templates/security/remove-watermark.html | 2 +- .../resources/templates/security/sanitize-pdf.html | 2 +- 52 files changed, 28 insertions(+), 139 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/controller/api/CropController.java b/src/main/java/stirling/software/SPDF/controller/api/CropController.java index 8f8deafc..d2723cce 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/CropController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/CropController.java @@ -16,13 +16,9 @@ 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.RequestParam; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.general.CropPdfForm; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/MergeController.java b/src/main/java/stirling/software/SPDF/controller/api/MergeController.java index f256b692..4727e195 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/MergeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/MergeController.java @@ -18,16 +18,11 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; -import stirling.software.SPDF.model.api.general.CropPdfForm; import stirling.software.SPDF.model.api.general.MergePdfsRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java index 4264f844..2f990381 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java @@ -17,13 +17,10 @@ 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.RequestParam; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.general.MergeMultiplePagesRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/RotationController.java b/src/main/java/stirling/software/SPDF/controller/api/RotationController.java index be3fcbff..ed527549 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RotationController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RotationController.java @@ -11,13 +11,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.general.RotatePDFRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java index 4e155d1d..e47aa6c5 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java @@ -18,13 +18,10 @@ 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.RequestParam; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.general.ScalePagesRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java index 6ddf42f4..8d64ca07 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java @@ -20,16 +20,12 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFWithPageNums; -import stirling.software.SPDF.utils.GeneralUtils; import stirling.software.SPDF.utils.WebResponseUtils; @RestController diff --git a/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java b/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java index 28697531..22bf1d70 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/ToSinglePageController.java @@ -16,12 +16,9 @@ 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.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java index 8fd9d809..e821a36a 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertEpubToPdf.java @@ -17,7 +17,6 @@ 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import org.w3c.dom.Document; @@ -29,7 +28,6 @@ import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.GeneralFile; -import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.FileToPdf; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java index f6a2036b..5839dd2d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertHtmlToPDF.java @@ -1,12 +1,9 @@ package stirling.software.SPDF.controller.api.converters; -import java.io.IOException; - 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java index e65d1f3c..6c100519 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java @@ -14,14 +14,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.converters.ConvertToImageRequest; import stirling.software.SPDF.model.api.converters.ConvertToPdfRequest; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java index 4726562f..4191ecdf 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertMarkdownToPdf.java @@ -1,7 +1,5 @@ package stirling.software.SPDF.controller.api.converters; -import java.io.IOException; - import org.commonmark.node.Node; import org.commonmark.parser.Parser; import org.commonmark.renderer.html.HtmlRenderer; @@ -9,7 +7,6 @@ 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java index f5f5bc27..e1c18a49 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java @@ -13,12 +13,10 @@ 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.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.GeneralFile; import stirling.software.SPDF.utils.ProcessExecutor; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java index 52ac5a8d..11279a27 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java @@ -6,16 +6,11 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; -import stirling.software.SPDF.model.api.GeneralFile; import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.model.api.converters.PdfToPresentationRequest; import stirling.software.SPDF.model.api.converters.PdfToTextOrRTFRequest; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java index 90f4f06d..32ccb84a 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java @@ -1,6 +1,5 @@ package stirling.software.SPDF.controller.api.converters; -import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -10,12 +9,10 @@ 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.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.ProcessExecutor; diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java index 580fe3a5..7c81edf2 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertWebsiteToPDF.java @@ -10,11 +10,9 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.converters.UrlToPdfRequest; import stirling.software.SPDF.utils.GeneralUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java b/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java index 8218da33..bdbb6613 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/filters/FilterController.java @@ -9,13 +9,10 @@ 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.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFComparisonAndCount; import stirling.software.SPDF.model.api.PDFWithPageNums; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java index d26b0fee..fc576fd5 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java @@ -14,13 +14,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.ExtractHeaderRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java index 821fbec1..b4b9b951 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoSplitPdfController.java @@ -19,7 +19,6 @@ 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -32,7 +31,6 @@ import com.google.zxing.Result; import com.google.zxing.common.HybridBinarizer; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.AutoSplitPdfRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java index afad69e3..c52ff61a 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/BlankPageController.java @@ -23,13 +23,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.RemoveBlankPagesRequest; import stirling.software.SPDF.utils.PdfUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java index d8fdb0d4..1d66674a 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java @@ -25,14 +25,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.OptimizePdfRequest; import stirling.software.SPDF.utils.GeneralUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java index c725ea1a..d5906970 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java @@ -25,21 +25,17 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.ExtractImageScansRequest; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; @RestController @RequestMapping("/api/v1/misc") @Tag(name = "Misc", description = "Miscellaneous APIs") 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 6546363c..03d21e64 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 @@ -23,14 +23,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFWithImageFormatRequest; import stirling.software.SPDF.utils.WebResponseUtils; 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 21b3d4e2..68e026ab 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 @@ -33,13 +33,11 @@ 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java index 836e2200..6ab7c92b 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java @@ -14,13 +14,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.MetadataRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java index bc0e7938..22db7fc3 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java @@ -21,14 +21,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.ProcessPdfWithOcrRequest; import stirling.software.SPDF.utils.ProcessExecutor; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java index 5cf6af8d..e28f7535 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OverlayImageController.java @@ -9,13 +9,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.OverlayImageRequest; import stirling.software.SPDF.utils.PdfUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java index e7f7f4cb..61a1ec97 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/PageNumbersController.java @@ -16,13 +16,10 @@ 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.RequestParam; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.misc.AddPageNumbersRequest; import stirling.software.SPDF.utils.GeneralUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java index 1a0b73b5..f9ae541d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/RepairController.java @@ -12,15 +12,12 @@ 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.RequestPart; 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.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFFile; -import stirling.software.SPDF.model.api.misc.AddPageNumbersRequest; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.ProcessExecutor.ProcessExecutorResult; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java index 8295f034..27431346 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ShowJavascript.java @@ -12,7 +12,6 @@ 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; diff --git a/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java b/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java index 5a3f1389..c12fe724 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/pipeline/PipelineController.java @@ -40,8 +40,6 @@ import org.springframework.util.MultiValueMap; 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; 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 9e17f2fe..34ee0ec2 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 @@ -47,14 +47,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.security.SignPDFWithCertRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java b/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java index 638d7cf6..7b4aed65 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/GetInfoOnPDF.java @@ -63,7 +63,6 @@ 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.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -72,7 +71,6 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.PDFFile; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java index 8bec2e82..639b6973 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java @@ -11,14 +11,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.security.AddPasswordRequest; import stirling.software.SPDF.model.api.security.PDFPasswordRequest; diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java b/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java index d66e3003..825544dc 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/RedactController.java @@ -21,13 +21,10 @@ 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.RequestParam; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.PDFText; import stirling.software.SPDF.model.api.security.RedactPdfRequest; diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java index d867cf1d..b7fbfb0d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java @@ -23,13 +23,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; import stirling.software.SPDF.model.api.security.SanitizePdfRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java index eee30119..b19636cd 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java @@ -25,14 +25,10 @@ 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.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; 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.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.api.security.AddWatermarkRequest; import stirling.software.SPDF.utils.WebResponseUtils; diff --git a/src/main/java/stirling/software/SPDF/model/api/general/MergePdfsRequest.java b/src/main/java/stirling/software/SPDF/model/api/general/MergePdfsRequest.java index c6d3f98c..b7b3bda7 100644 --- a/src/main/java/stirling/software/SPDF/model/api/general/MergePdfsRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/general/MergePdfsRequest.java @@ -18,5 +18,5 @@ public class MergePdfsRequest extends MultiplePDFFiles { "byPDFTitle" }, defaultValue = "orderProvided") - private String sortType; + private String sortType = "orderProvided"; } diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/ExtractImageScansRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/ExtractImageScansRequest.java index f063e4fc..1a575fe6 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/ExtractImageScansRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/ExtractImageScansRequest.java @@ -13,17 +13,17 @@ public class ExtractImageScansRequest { private MultipartFile fileInput; @Schema(description = "The angle threshold for the image scan extraction", defaultValue = "5", example = "5") - private int angleThreshold; + private int angleThreshold = 5; @Schema(description = "The tolerance for the image scan extraction", defaultValue = "20", example = "20") - private int tolerance; + private int tolerance = 20; @Schema(description = "The minimum area for the image scan extraction", defaultValue = "8000", example = "8000") - private int minArea; + private int minArea = 8000; @Schema(description = "The minimum contour area for the image scan extraction", defaultValue = "500", example = "500") - private int minContourArea; + private int minContourArea = 500; @Schema(description = "The border size for the image scan extraction", defaultValue = "1", example = "1") - private int borderSize; + private int borderSize =1; } diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java index 689e4211..da2703e5 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java @@ -30,7 +30,7 @@ public class ProcessPdfWithOcrRequest extends PDFFile { private String ocrType; @Schema(description = "Specify the OCR render type, either 'hocr' or 'sandwich'", allowableValues = {"hocr", "sandwich"}, defaultValue = "hocr") - private String ocrRenderType; + private String ocrRenderType = "hocr"; @Schema(description = "Remove images from the output PDF if set to true") private Boolean removeImagesAfter; diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/RemoveBlankPagesRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/RemoveBlankPagesRequest.java index 3f20e2f7..0d2e11c7 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/RemoveBlankPagesRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/RemoveBlankPagesRequest.java @@ -10,8 +10,8 @@ import stirling.software.SPDF.model.api.PDFFile; public class RemoveBlankPagesRequest extends PDFFile { @Schema(description = "The threshold value to determine blank pages", example = "10", defaultValue = "10") - private int threshold; + private int threshold = 10; @Schema(description = "The percentage of white color on a page to consider it as blank", example = "99.9", defaultValue = "99.9") - private float whitePercent; + private float whitePercent = 99.9f; } diff --git a/src/main/java/stirling/software/SPDF/model/api/security/AddPasswordRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/AddPasswordRequest.java index 06a52d4f..ea83e470 100644 --- a/src/main/java/stirling/software/SPDF/model/api/security/AddPasswordRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/security/AddPasswordRequest.java @@ -16,7 +16,7 @@ public class AddPasswordRequest extends PDFFile { private String password; @Schema(description = "The length of the encryption key", allowableValues = {"40", "128", "256"}, defaultValue = "256") - private int keyLength; + private int keyLength = 256; @Schema(description = "Whether the document assembly is allowed", example = "false") private boolean canAssembleDocument; diff --git a/src/main/java/stirling/software/SPDF/model/api/security/AddWatermarkRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/AddWatermarkRequest.java index 5fa3f0fb..cd800948 100644 --- a/src/main/java/stirling/software/SPDF/model/api/security/AddWatermarkRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/security/AddWatermarkRequest.java @@ -11,7 +11,9 @@ import stirling.software.SPDF.model.api.PDFFile; @EqualsAndHashCode(callSuper=true) public class AddWatermarkRequest extends PDFFile { - @Schema(description = "The watermark type (text or image)", required = true) + @Schema(description = "The watermark type (text or image)", + allowableValues = {"text", "image"}, + required = true) private String watermarkType; @Schema(description = "The watermark text") @@ -23,13 +25,13 @@ public class AddWatermarkRequest extends PDFFile { @Schema(description = "The selected alphabet", allowableValues = {"roman", "arabic", "japanese", "korean", "chinese"}, defaultValue = "roman") - private String alphabet; + private String alphabet = "roman"; @Schema(description = "The font size of the watermark text", example = "30") - private float fontSize; + private float fontSize = 30; @Schema(description = "The rotation of the watermark in degrees", example = "0") - private float rotation; + private float rotation = 0; @Schema(description = "The opacity of the watermark (0.0 - 1.0)", example = "0.5") private float opacity; diff --git a/src/main/java/stirling/software/SPDF/model/api/security/RedactPdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/RedactPdfRequest.java index 1f77bd03..1966c53a 100644 --- a/src/main/java/stirling/software/SPDF/model/api/security/RedactPdfRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/security/RedactPdfRequest.java @@ -19,7 +19,7 @@ public class RedactPdfRequest extends PDFFile { private boolean wholeWordSearch; @Schema(description = "The color for redaction", defaultValue = "#000000") - private String redactColor; + private String redactColor = "#000000"; @Schema(description = "Custom padding for redaction", type = "number") private float customPadding; diff --git a/src/main/resources/templates/security/add-password.html b/src/main/resources/templates/security/add-password.html index b0201158..093f226c 100644 --- a/src/main/resources/templates/security/add-password.html +++ b/src/main/resources/templates/security/add-password.html @@ -13,7 +13,7 @@

    - +
    diff --git a/src/main/resources/templates/security/add-watermark.html b/src/main/resources/templates/security/add-watermark.html index 6a0619ec..1943b365 100644 --- a/src/main/resources/templates/security/add-watermark.html +++ b/src/main/resources/templates/security/add-watermark.html @@ -13,7 +13,7 @@

    - +
    diff --git a/src/main/resources/templates/security/auto-redact.html b/src/main/resources/templates/security/auto-redact.html index 2af1fa45..ec355781 100644 --- a/src/main/resources/templates/security/auto-redact.html +++ b/src/main/resources/templates/security/auto-redact.html @@ -11,7 +11,7 @@

    - +
    diff --git a/src/main/resources/templates/security/cert-sign.html b/src/main/resources/templates/security/cert-sign.html index 9435e67e..fc2e0b8f 100644 --- a/src/main/resources/templates/security/cert-sign.html +++ b/src/main/resources/templates/security/cert-sign.html @@ -16,7 +16,7 @@

    -
    diff --git a/src/main/resources/templates/security/change-permissions.html b/src/main/resources/templates/security/change-permissions.html index 196f05ab..f40ee7b2 100644 --- a/src/main/resources/templates/security/change-permissions.html +++ b/src/main/resources/templates/security/change-permissions.html @@ -14,7 +14,7 @@

    - +
    diff --git a/src/main/resources/templates/security/get-info-on-pdf.html b/src/main/resources/templates/security/get-info-on-pdf.html index d5cc3eca..b1d52335 100644 --- a/src/main/resources/templates/security/get-info-on-pdf.html +++ b/src/main/resources/templates/security/get-info-on-pdf.html @@ -14,7 +14,7 @@

    + th:action="@{api/v1/security/get-info-on-pdf}">

    diff --git a/src/main/resources/templates/security/remove-password.html b/src/main/resources/templates/security/remove-password.html index 1e95f403..cec61959 100644 --- a/src/main/resources/templates/security/remove-password.html +++ b/src/main/resources/templates/security/remove-password.html @@ -13,7 +13,7 @@

    - +
    diff --git a/src/main/resources/templates/security/remove-watermark.html b/src/main/resources/templates/security/remove-watermark.html index 83c83937..8f818998 100644 --- a/src/main/resources/templates/security/remove-watermark.html +++ b/src/main/resources/templates/security/remove-watermark.html @@ -13,7 +13,7 @@

    - +
    diff --git a/src/main/resources/templates/security/sanitize-pdf.html b/src/main/resources/templates/security/sanitize-pdf.html index dfd1f310..bac18a2e 100644 --- a/src/main/resources/templates/security/sanitize-pdf.html +++ b/src/main/resources/templates/security/sanitize-pdf.html @@ -13,7 +13,7 @@

    - +
    From 2c0fb335482cb717d86dd200b71a087518255f26 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Tue, 12 Sep 2023 00:42:22 +0100 Subject: [PATCH 08/13] slow rework testing, still on multipage --- .../api/RearrangePagesPDFController.java | 2 -- .../controller/api/SplitPDFController.java | 2 ++ .../controller/web/GeneralWebController.java | 9 +++++ .../controller/web/OtherWebController.java | 35 ++++++++----------- .../software/SPDF/utils/GeneralUtils.java | 2 +- .../{misc => }/multi-page-layout.html | 2 +- .../resources/templates/pdf-organizer.html | 2 +- src/main/resources/templates/split-pdfs.html | 2 +- 8 files changed, 29 insertions(+), 27 deletions(-) rename src/main/resources/templates/{misc => }/multi-page-layout.html (95%) diff --git a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java index 8ca5fc0f..0f045161 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java @@ -180,8 +180,6 @@ public class RearrangePagesPDFController { // Split the page order string into an array of page numbers or range of numbers String[] pageOrderArr = pageOrder != null ? pageOrder.split(",") : new String[0]; int totalPages = document.getNumberOfPages(); - System.out.println("pageOrder=" + pageOrder); - System.out.println("SortTypes length =" + sortType.length()); List newPageOrder; if (sortType != null && sortType.length() > 0) { newPageOrder = processSortTypes(sortType, totalPages); diff --git a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java index 8d64ca07..d633bf40 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java @@ -46,6 +46,8 @@ public class SplitPDFController { PDDocument document = PDDocument.load(inputStream); List pageNumbers = request.getPageNumbersList(document); + if(!pageNumbers.contains(document.getNumberOfPages() - 1)) + pageNumbers.add(document.getNumberOfPages()- 1); logger.info("Splitting PDF into pages: {}", pageNumbers.stream().map(String::valueOf).collect(Collectors.joining(","))); // split the document diff --git a/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java b/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java index 2571c785..38bdd9e8 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java @@ -140,6 +140,15 @@ public class GeneralWebController { return "sign"; } + @GetMapping("/multi-page-layout") + @Hidden + public String multiPageLayoutForm(Model model) { + model.addAttribute("currentPage", "multi-page-layout"); + return "multi-page-layout"; + } + + + @Autowired private ResourceLoader resourceLoader; diff --git a/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java b/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java index 157f76e4..450d662c 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java @@ -21,7 +21,7 @@ public class OtherWebController { @Hidden public String compressPdfForm(Model model) { model.addAttribute("currentPage", "compress-pdf"); - return "other/compress-pdf"; + return "misc/compress-pdf"; } @GetMapping("/extract-image-scans") @@ -36,7 +36,7 @@ public class OtherWebController { @Hidden public String extractJavascriptForm(Model model) { model.addAttribute("currentPage", "show-javascript"); - return "other/show-javascript"; + return "misc/show-javascript"; } @@ -44,21 +44,21 @@ public class OtherWebController { @Hidden public String addPageNumbersForm(Model model) { model.addAttribute("currentPage", "add-page-numbers"); - return "other/add-page-numbers"; + return "misc/add-page-numbers"; } @GetMapping("/extract-images") @Hidden public String extractImagesForm(Model model) { model.addAttribute("currentPage", "extract-images"); - return "other/extract-images"; + return "misc/extract-images"; } @GetMapping("/flatten") @Hidden public String flattenForm(Model model) { model.addAttribute("currentPage", "flatten"); - return "other/flatten"; + return "misc/flatten"; } @@ -67,14 +67,14 @@ public class OtherWebController { @Hidden public String addWatermarkForm(Model model) { model.addAttribute("currentPage", "change-metadata"); - return "other/change-metadata"; + return "misc/change-metadata"; } @GetMapping("/compare") @Hidden public String compareForm(Model model) { model.addAttribute("currentPage", "compare"); - return "other/compare"; + return "misc/compare"; } public List getAvailableTesseractLanguages() { @@ -103,56 +103,49 @@ public class OtherWebController { @Hidden public String overlayImage(Model model) { model.addAttribute("currentPage", "add-image"); - return "other/add-image"; + return "misc/add-image"; } @GetMapping("/adjust-contrast") @Hidden public String contrast(Model model) { model.addAttribute("currentPage", "adjust-contrast"); - return "other/adjust-contrast"; + return "misc/adjust-contrast"; } @GetMapping("/repair") @Hidden public String repairForm(Model model) { model.addAttribute("currentPage", "repair"); - return "other/repair"; + return "misc/repair"; } @GetMapping("/remove-blanks") @Hidden public String removeBlanksForm(Model model) { model.addAttribute("currentPage", "remove-blanks"); - return "other/remove-blanks"; - } - - @GetMapping("/multi-page-layout") - @Hidden - public String multiPageLayoutForm(Model model) { - model.addAttribute("currentPage", "multi-page-layout"); - return "other/multi-page-layout"; + return "misc/remove-blanks"; } @GetMapping("/scale-pages") @Hidden public String scalePagesFrom(Model model) { model.addAttribute("currentPage", "scale-pages"); - return "other/scale-pages"; + return "misc/scale-pages"; } @GetMapping("/auto-crop") @Hidden public String autoCropForm(Model model) { model.addAttribute("currentPage", "auto-crop"); - return "other/auto-crop"; + return "misc/auto-crop"; } @GetMapping("/auto-rename") @Hidden public String autoRenameForm(Model model) { model.addAttribute("currentPage", "auto-rename"); - return "other/auto-rename"; + return "misc/auto-rename"; } diff --git a/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java b/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java index b4377039..3097fc1b 100644 --- a/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java +++ b/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java @@ -76,7 +76,7 @@ public class GeneralUtils { } public static List parsePageString(String pageOrder, int totalPages) { - return parsePageList(pageOrder.split(","), 100); + return parsePageList(pageOrder.split(","), totalPages); } public static List parsePageList(String[] pageOrderArr, int totalPages) { List newPageOrder = new ArrayList<>(); diff --git a/src/main/resources/templates/misc/multi-page-layout.html b/src/main/resources/templates/multi-page-layout.html similarity index 95% rename from src/main/resources/templates/misc/multi-page-layout.html rename to src/main/resources/templates/multi-page-layout.html index 9f2f5373..6b1de771 100644 --- a/src/main/resources/templates/misc/multi-page-layout.html +++ b/src/main/resources/templates/multi-page-layout.html @@ -14,7 +14,7 @@

    - +
    diff --git a/src/main/resources/templates/pdf-organizer.html b/src/main/resources/templates/pdf-organizer.html index 696245cb..67b9ba94 100644 --- a/src/main/resources/templates/pdf-organizer.html +++ b/src/main/resources/templates/pdf-organizer.html @@ -32,7 +32,7 @@
    - +
    diff --git a/src/main/resources/templates/split-pdfs.html b/src/main/resources/templates/split-pdfs.html index a8a59e02..5ba3a57a 100644 --- a/src/main/resources/templates/split-pdfs.html +++ b/src/main/resources/templates/split-pdfs.html @@ -28,7 +28,7 @@
    - +

    From 82b641458f9a8525d0e8d714374d0da97398d490 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Wed, 13 Sep 2023 00:46:30 +0100 Subject: [PATCH 09/13] fixes --- .../api/MultiPageLayoutController.java | 100 ++++++++++-------- .../api/RearrangePagesPDFController.java | 3 +- .../controller/api/ScalePagesController.java | 2 +- .../api/misc/AutoRenameController.java | 2 +- .../api/misc/CompressController.java | 2 +- .../api/misc/MetadataController.java | 6 +- .../controller/api/misc/OCRController.java | 12 +-- .../api/security/CertSignController.java | 2 +- .../api/security/SanitizeController.java | 10 +- .../controller/web/GeneralWebController.java | 8 ++ .../controller/web/OtherWebController.java | 12 +-- .../SPDF/model/api/PDFWithPageSize.java | 16 +++ .../model/api/general/ScalePagesRequest.java | 10 +- .../model/api/misc/ExtractHeaderRequest.java | 2 +- .../SPDF/model/api/misc/MetadataRequest.java | 2 +- .../model/api/misc/OptimizePdfRequest.java | 2 +- .../api/misc/ProcessPdfWithOcrRequest.java | 12 +-- .../api/security/SanitizePdfRequest.java | 10 +- .../api/security/SignPDFWithCertRequest.java | 2 +- .../templates/{misc => }/auto-split-pdf.html | 0 .../resources/templates/extract-page.html | 2 +- .../templates/{misc => }/scale-pages.html | 2 +- .../templates/security/get-info-on-pdf.html | 2 +- 23 files changed, 121 insertions(+), 100 deletions(-) create mode 100644 src/main/java/stirling/software/SPDF/model/api/PDFWithPageSize.java rename src/main/resources/templates/{misc => }/auto-split-pdf.html (100%) rename src/main/resources/templates/{misc => }/scale-pages.html (96%) diff --git a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java index 2f990381..f899736f 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java @@ -39,63 +39,69 @@ public class MultiPageLayoutController { ) public ResponseEntity mergeMultiplePagesIntoOne(@ModelAttribute MergeMultiplePagesRequest request) throws IOException { - - int pagesPerSheet = request.getPagesPerSheet(); - MultipartFile file = request.getFileInput(); - if (pagesPerSheet != 2 && pagesPerSheet != 3 && pagesPerSheet != (int) Math.sqrt(pagesPerSheet) * Math.sqrt(pagesPerSheet)) { - throw new IllegalArgumentException("pagesPerSheet must be 2, 3 or a perfect square"); - } - int cols = pagesPerSheet == 2 || pagesPerSheet == 3 ? pagesPerSheet : (int) Math.sqrt(pagesPerSheet); - int rows = pagesPerSheet == 2 || pagesPerSheet == 3 ? 1 : (int) Math.sqrt(pagesPerSheet); + int pagesPerSheet = request.getPagesPerSheet(); + MultipartFile file = request.getFileInput(); - PDDocument sourceDocument = PDDocument.load(file.getInputStream()); - PDDocument newDocument = new PDDocument(); - PDPage newPage = new PDPage(PDRectangle.A4); - newDocument.addPage(newPage); + if (pagesPerSheet != 2 && pagesPerSheet != 3 && pagesPerSheet != (int) Math.sqrt(pagesPerSheet) * Math.sqrt(pagesPerSheet)) { + throw new IllegalArgumentException("pagesPerSheet must be 2, 3 or a perfect square"); + } - int totalPages = sourceDocument.getNumberOfPages(); - float cellWidth = newPage.getMediaBox().getWidth() / cols; - float cellHeight = newPage.getMediaBox().getHeight() / rows; + int cols = pagesPerSheet == 2 || pagesPerSheet == 3 ? pagesPerSheet : (int) Math.sqrt(pagesPerSheet); + int rows = pagesPerSheet == 2 || pagesPerSheet == 3 ? 1 : (int) Math.sqrt(pagesPerSheet); - PDPageContentStream contentStream = new PDPageContentStream(newDocument, newPage, PDPageContentStream.AppendMode.APPEND, true, true); + PDDocument sourceDocument = PDDocument.load(file.getInputStream()); + PDDocument newDocument = new PDDocument(); + PDPage newPage = new PDPage(PDRectangle.A4); + newDocument.addPage(newPage); - LayerUtility layerUtility = new LayerUtility(newDocument); + int totalPages = sourceDocument.getNumberOfPages(); + float cellWidth = newPage.getMediaBox().getWidth() / cols; + float cellHeight = newPage.getMediaBox().getHeight() / rows; - for (int i = 0; i < totalPages; i++) { - PDPage sourcePage = sourceDocument.getPage(i); - System.out.println("Reading page " + (i+1)); - PDRectangle rect = sourcePage.getMediaBox(); - float scaleWidth = cellWidth / rect.getWidth(); - float scaleHeight = cellHeight / rect.getHeight(); - float scale = Math.min(scaleWidth, scaleHeight); - System.out.println("Scale for page " + (i+1) + ": " + scale); + PDPageContentStream contentStream = new PDPageContentStream(newDocument, newPage, PDPageContentStream.AppendMode.APPEND, true, true); + LayerUtility layerUtility = new LayerUtility(newDocument); + + for (int i = 0; i < totalPages; i++) { + if (i != 0 && i % pagesPerSheet == 0) { + // Close the current content stream and create a new page and content stream + contentStream.close(); + newPage = new PDPage(PDRectangle.A4); + newDocument.addPage(newPage); + contentStream = new PDPageContentStream(newDocument, newPage, PDPageContentStream.AppendMode.APPEND, true, true); + } + + PDPage sourcePage = sourceDocument.getPage(i); + PDRectangle rect = sourcePage.getMediaBox(); + float scaleWidth = cellWidth / rect.getWidth(); + float scaleHeight = cellHeight / rect.getHeight(); + float scale = Math.min(scaleWidth, scaleHeight); + + int adjustedPageIndex = i % pagesPerSheet; // This will reset the index for every new page + int rowIndex = adjustedPageIndex / cols; + int colIndex = adjustedPageIndex % cols; + + float x = colIndex * cellWidth + (cellWidth - rect.getWidth() * scale) / 2; + float y = newPage.getMediaBox().getHeight() - ((rowIndex + 1) * cellHeight - (cellHeight - rect.getHeight() * scale) / 2); + + contentStream.saveGraphicsState(); + contentStream.transform(Matrix.getTranslateInstance(x, y)); + contentStream.transform(Matrix.getScaleInstance(scale, scale)); + + PDFormXObject formXObject = layerUtility.importPageAsForm(sourceDocument, i); + contentStream.drawForm(formXObject); + + contentStream.restoreGraphicsState(); + } - int rowIndex = i / cols; - int colIndex = i % cols; + contentStream.close(); // Close the final content stream + sourceDocument.close(); - float x = colIndex * cellWidth + (cellWidth - rect.getWidth() * scale) / 2; - float y = newPage.getMediaBox().getHeight() - ((rowIndex + 1) * cellHeight - (cellHeight - rect.getHeight() * scale) / 2); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + newDocument.save(baos); + newDocument.close(); - contentStream.saveGraphicsState(); - contentStream.transform(Matrix.getTranslateInstance(x, y)); - contentStream.transform(Matrix.getScaleInstance(scale, scale)); - - PDFormXObject formXObject = layerUtility.importPageAsForm(sourceDocument, i); - contentStream.drawForm(formXObject); - - contentStream.restoreGraphicsState(); - } - - - contentStream.close(); - sourceDocument.close(); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - newDocument.save(baos); - newDocument.close(); - byte[] result = baos.toByteArray(); return WebResponseUtils.bytesToWebResponse(result, file.getOriginalFilename().replaceFirst("[.][^.]+$", "") + "_layoutChanged.pdf"); } diff --git a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java index 0f045161..9dd607b8 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java @@ -186,7 +186,8 @@ public class RearrangePagesPDFController { } else { newPageOrder = GeneralUtils.parsePageList(pageOrderArr, totalPages); } - + logger.info("newPageOrder = " +newPageOrder); + logger.info("totalPages = " +totalPages); // Create a new list to hold the pages in the new order List newPages = new ArrayList<>(); for (int i = 0; i < newPageOrder.size(); i++) { diff --git a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java index e47aa6c5..743ea6b1 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java @@ -36,7 +36,7 @@ public class ScalePagesController { @Operation(summary = "Change the size of a PDF page/document", description = "This operation takes an input PDF file and the size to scale the pages to in the output PDF file. Input:PDF Output:PDF Type:SISO") public ResponseEntity scalePages(@ModelAttribute ScalePagesRequest request) throws IOException { MultipartFile file = request.getFileInput(); - String targetPDRectangle = request.getTargetPDRectangle(); + String targetPDRectangle = request.getPageSize(); float scaleFactor = request.getScaleFactor(); Map sizeMap = new HashMap<>(); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java index fc576fd5..fe8337d2 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/AutoRenameController.java @@ -35,7 +35,7 @@ public class AutoRenameController { @Operation(summary = "Extract header from PDF file", description = "This endpoint accepts a PDF file and attempts to extract its title or header based on heuristics. Input:PDF Output:PDF Type:SISO") public ResponseEntity extractHeader(@ModelAttribute ExtractHeaderRequest request) throws Exception { MultipartFile file = request.getFileInput(); - Boolean useFirstTextAsFallback = request.getUseFirstTextAsFallback(); + Boolean useFirstTextAsFallback = request.isUseFirstTextAsFallback(); PDDocument document = PDDocument.load(file.getInputStream()); PDFTextStripper reader = new PDFTextStripper() { diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java index 1d66674a..dd864bc1 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/CompressController.java @@ -48,7 +48,7 @@ public class CompressController { public ResponseEntity optimizePdf(@ModelAttribute OptimizePdfRequest request) throws Exception { MultipartFile inputFile = request.getFileInput(); Integer optimizeLevel = request.getOptimizeLevel(); - String expectedOutputSizeString = request.getExpectedOutputSizeString(); + String expectedOutputSizeString = request.getExpectedOutputSize(); if(expectedOutputSizeString == null && optimizeLevel == null) { diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java index 6ab7c92b..027c6240 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/MetadataController.java @@ -48,7 +48,7 @@ public class MetadataController { MultipartFile pdfFile = request.getFileInput(); // Extract metadata information - Boolean deleteAll = request.getDeleteAll(); + Boolean deleteAll = request.isDeleteAll(); String author = request.getAuthor(); String creationDate = request.getCreationDate(); String creator = request.getCreator(); @@ -61,7 +61,9 @@ public class MetadataController { // Extract additional custom parameters Map allRequestParams = request.getAllRequestParams(); - + if(allRequestParams == null) { + allRequestParams = new java.util.HashMap(); + } // Load the PDF file into a PDDocument PDDocument document = PDDocument.load(pdfFile.getBytes()); diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java index 22db7fc3..5ee06c19 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java @@ -53,14 +53,14 @@ public class OCRController { description = "This endpoint processes a PDF file using OCR (Optical Character Recognition). Users can specify languages, sidecar, deskew, clean, cleanFinal, ocrType, ocrRenderType, and removeImagesAfter options. Input:PDF Output:PDF Type:SI-Conditional") public ResponseEntity processPdfWithOCR(@ModelAttribute ProcessPdfWithOcrRequest request) throws IOException, InterruptedException { MultipartFile inputFile = request.getFileInput(); - List selectedLanguages = request.getSelectedLanguages(); - Boolean sidecar = request.getSidecar(); - Boolean deskew = request.getDeskew(); - Boolean clean = request.getClean(); - Boolean cleanFinal = request.getCleanFinal(); + List selectedLanguages = request.getLanguages(); + Boolean sidecar = request.isSidecar(); + Boolean deskew = request.isDeskew(); + Boolean clean = request.isClean(); + Boolean cleanFinal = request.isCleanFinal(); String ocrType = request.getOcrType(); String ocrRenderType = request.getOcrRenderType(); - Boolean removeImagesAfter = request.getRemoveImagesAfter(); + Boolean removeImagesAfter = request.isRemoveImagesAfter(); // --output-type pdfa if (selectedLanguages == null || selectedLanguages.isEmpty()) { throw new IOException("Please select at least one language."); 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 34ee0ec2..b580b4c9 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 @@ -75,7 +75,7 @@ public class CertSignController { MultipartFile certFile = request.getCertFile(); MultipartFile p12File = request.getP12File(); String password = request.getPassword(); - Boolean showSignature = request.getShowSignature(); + Boolean showSignature = request.isShowSignature(); String reason = request.getReason(); String location = request.getLocation(); String name = request.getName(); diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java index b7fbfb0d..206a65b4 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java @@ -39,11 +39,11 @@ public class SanitizeController { description = "This endpoint processes a PDF file and removes specific elements based on the provided options. Input:PDF Output:PDF Type:SISO") public ResponseEntity sanitizePDF(@ModelAttribute SanitizePdfRequest request) throws IOException { MultipartFile inputFile = request.getFileInput(); - Boolean removeJavaScript = request.getRemoveJavaScript(); - Boolean removeEmbeddedFiles = request.getRemoveEmbeddedFiles(); - Boolean removeMetadata = request.getRemoveMetadata(); - Boolean removeLinks = request.getRemoveLinks(); - Boolean removeFonts = request.getRemoveFonts(); + boolean removeJavaScript = request.isRemoveJavaScript(); + boolean removeEmbeddedFiles = request.isRemoveEmbeddedFiles(); + boolean removeMetadata = request.isRemoveMetadata(); + boolean removeLinks = request.isRemoveLinks(); + boolean removeFonts = request.isRemoveFonts(); try (PDDocument document = PDDocument.load(inputFile.getInputStream())) { if (removeJavaScript) { diff --git a/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java b/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java index 38bdd9e8..6c934290 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java @@ -148,6 +148,14 @@ public class GeneralWebController { } + @GetMapping("/scale-pages") + @Hidden + public String scalePagesFrom(Model model) { + model.addAttribute("currentPage", "scale-pages"); + return "scale-pages"; + } + + @Autowired private ResourceLoader resourceLoader; diff --git a/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java b/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java index 450d662c..721ca83d 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java @@ -27,7 +27,7 @@ public class OtherWebController { @GetMapping("/extract-image-scans") @Hidden public ModelAndView extractImageScansForm() { - ModelAndView modelAndView = new ModelAndView("other/extract-image-scans"); + ModelAndView modelAndView = new ModelAndView("misc/extract-image-scans"); modelAndView.addObject("currentPage", "extract-image-scans"); return modelAndView; } @@ -90,7 +90,7 @@ public class OtherWebController { @GetMapping("/ocr-pdf") @Hidden public ModelAndView ocrPdfPage() { - ModelAndView modelAndView = new ModelAndView("other/ocr-pdf"); + ModelAndView modelAndView = new ModelAndView("misc/ocr-pdf"); List languages = getAvailableTesseractLanguages(); Collections.sort(languages); modelAndView.addObject("languages", languages); @@ -127,13 +127,7 @@ public class OtherWebController { return "misc/remove-blanks"; } - @GetMapping("/scale-pages") - @Hidden - public String scalePagesFrom(Model model) { - model.addAttribute("currentPage", "scale-pages"); - return "misc/scale-pages"; - } - + @GetMapping("/auto-crop") @Hidden public String autoCropForm(Model model) { diff --git a/src/main/java/stirling/software/SPDF/model/api/PDFWithPageSize.java b/src/main/java/stirling/software/SPDF/model/api/PDFWithPageSize.java new file mode 100644 index 00000000..661a4ffe --- /dev/null +++ b/src/main/java/stirling/software/SPDF/model/api/PDFWithPageSize.java @@ -0,0 +1,16 @@ +package stirling.software.SPDF.model.api; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper=true) +public class PDFWithPageSize extends PDFFile { + + @Schema(description = "The scale of pages in the output PDF. Acceptable values are A0-A6, LETTER, LEGAL.", + allowableValues = { + "A0", "A1", "A2", "A3", "A4", "A5", "A6", "LETTER", "LEGAL" + }) + private String pageSize; +} diff --git a/src/main/java/stirling/software/SPDF/model/api/general/ScalePagesRequest.java b/src/main/java/stirling/software/SPDF/model/api/general/ScalePagesRequest.java index 51bdc5fc..28be3990 100644 --- a/src/main/java/stirling/software/SPDF/model/api/general/ScalePagesRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/general/ScalePagesRequest.java @@ -4,17 +4,11 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import stirling.software.SPDF.model.api.PDFFile; +import stirling.software.SPDF.model.api.PDFWithPageSize; @Data @EqualsAndHashCode(callSuper=true) -public class ScalePagesRequest extends PDFFile { - - @Schema(description = "The scale of pages in the output PDF. Acceptable values are A0-A10, B0-B9, LETTER, TABLOID, LEDGER, LEGAL, EXECUTIVE.", - allowableValues = { - "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "B0", "B1", "B2", "B3", "B4", - "B5", "B6", "B7", "B8", "B9", "LETTER", "TABLOID", "LEDGER", "LEGAL", "EXECUTIVE" - }) - private String targetPDRectangle; +public class ScalePagesRequest extends PDFWithPageSize { @Schema(description = "The scale of the content on the pages of the output PDF. Acceptable values are floats.") private float scaleFactor; diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/ExtractHeaderRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/ExtractHeaderRequest.java index 9dda0d6f..f3028445 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/ExtractHeaderRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/ExtractHeaderRequest.java @@ -10,5 +10,5 @@ import stirling.software.SPDF.model.api.PDFFile; public class ExtractHeaderRequest extends PDFFile { @Schema(description = "Flag indicating whether to use the first text as a fallback if no suitable title is found. Defaults to false.", required = false, defaultValue = "false") - private Boolean useFirstTextAsFallback; + private boolean useFirstTextAsFallback; } diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/MetadataRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/MetadataRequest.java index 0d909613..d62890aa 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/MetadataRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/MetadataRequest.java @@ -12,7 +12,7 @@ import stirling.software.SPDF.model.api.PDFFile; public class MetadataRequest extends PDFFile { @Schema(description = "Delete all metadata if set to true") - private Boolean deleteAll; + private boolean deleteAll; @Schema(description = "The author of the document") private String author; diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/OptimizePdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/OptimizePdfRequest.java index ca43b1eb..bc00cf20 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/OptimizePdfRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/OptimizePdfRequest.java @@ -14,5 +14,5 @@ public class OptimizePdfRequest extends PDFFile { private Integer optimizeLevel; @Schema(description = "The expected output size, e.g. '100MB', '25KB', etc.") - private String expectedOutputSizeString; + private String expectedOutputSize; } diff --git a/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java b/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java index da2703e5..392f8d54 100644 --- a/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java @@ -12,19 +12,19 @@ import stirling.software.SPDF.model.api.PDFFile; public class ProcessPdfWithOcrRequest extends PDFFile { @Schema(description = "List of languages to use in OCR processing") - private List selectedLanguages; + private List languages; @Schema(description = "Include OCR text in a sidecar text file if set to true") - private Boolean sidecar; + private boolean sidecar; @Schema(description = "Deskew the input file if set to true") - private Boolean deskew; + private boolean deskew; @Schema(description = "Clean the input file if set to true") - private Boolean clean; + private boolean clean; @Schema(description = "Clean the final output if set to true") - private Boolean cleanFinal; + private boolean cleanFinal; @Schema(description = "Specify the OCR type, e.g., 'skip-text', 'force-ocr', or 'Normal'", allowableValues = {"skip-text", "force-ocr", "Normal"}) private String ocrType; @@ -33,5 +33,5 @@ public class ProcessPdfWithOcrRequest extends PDFFile { private String ocrRenderType = "hocr"; @Schema(description = "Remove images from the output PDF if set to true") - private Boolean removeImagesAfter; + private boolean removeImagesAfter; } diff --git a/src/main/java/stirling/software/SPDF/model/api/security/SanitizePdfRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/SanitizePdfRequest.java index 310ee59c..98c7743f 100644 --- a/src/main/java/stirling/software/SPDF/model/api/security/SanitizePdfRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/security/SanitizePdfRequest.java @@ -10,17 +10,17 @@ import stirling.software.SPDF.model.api.PDFFile; public class SanitizePdfRequest extends PDFFile { @Schema(description = "Remove JavaScript actions from the PDF", defaultValue = "false") - private Boolean removeJavaScript; + private boolean removeJavaScript; @Schema(description = "Remove embedded files from the PDF", defaultValue = "false") - private Boolean removeEmbeddedFiles; + private boolean removeEmbeddedFiles; @Schema(description = "Remove metadata from the PDF", defaultValue = "false") - private Boolean removeMetadata; + private boolean removeMetadata; @Schema(description = "Remove links from the PDF", defaultValue = "false") - private Boolean removeLinks; + private boolean removeLinks; @Schema(description = "Remove fonts from the PDF", defaultValue = "false") - private Boolean removeFonts; + private boolean removeFonts; } diff --git a/src/main/java/stirling/software/SPDF/model/api/security/SignPDFWithCertRequest.java b/src/main/java/stirling/software/SPDF/model/api/security/SignPDFWithCertRequest.java index 5b2122c6..8e537c6a 100644 --- a/src/main/java/stirling/software/SPDF/model/api/security/SignPDFWithCertRequest.java +++ b/src/main/java/stirling/software/SPDF/model/api/security/SignPDFWithCertRequest.java @@ -27,7 +27,7 @@ public class SignPDFWithCertRequest extends PDFFile { private String password; @Schema(description = "Whether to visually show the signature in the PDF file") - private Boolean showSignature; + private boolean showSignature; @Schema(description = "The reason for signing the PDF") private String reason; diff --git a/src/main/resources/templates/misc/auto-split-pdf.html b/src/main/resources/templates/auto-split-pdf.html similarity index 100% rename from src/main/resources/templates/misc/auto-split-pdf.html rename to src/main/resources/templates/auto-split-pdf.html diff --git a/src/main/resources/templates/extract-page.html b/src/main/resources/templates/extract-page.html index a243461e..d8ae7fb5 100644 --- a/src/main/resources/templates/extract-page.html +++ b/src/main/resources/templates/extract-page.html @@ -18,7 +18,7 @@
    - +
    diff --git a/src/main/resources/templates/misc/scale-pages.html b/src/main/resources/templates/scale-pages.html similarity index 96% rename from src/main/resources/templates/misc/scale-pages.html rename to src/main/resources/templates/scale-pages.html index c252b9e1..1b59e38f 100644 --- a/src/main/resources/templates/misc/scale-pages.html +++ b/src/main/resources/templates/scale-pages.html @@ -14,7 +14,7 @@

    - +
    diff --git a/src/main/resources/templates/security/get-info-on-pdf.html b/src/main/resources/templates/security/get-info-on-pdf.html index b1d52335..f2de0919 100644 --- a/src/main/resources/templates/security/get-info-on-pdf.html +++ b/src/main/resources/templates/security/get-info-on-pdf.html @@ -40,7 +40,7 @@ const formData = new FormData(event.target); - fetch('get-info-on-pdf', { + fetch('api/v1/security/get-info-on-pdf', { method: 'POST', body: formData }) From fc4feb2096294c74c40cffa40e70374a8d00e767 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Thu, 14 Sep 2023 11:33:02 +0100 Subject: [PATCH 10/13] lang --- README.md | 9 +-- build.gradle | 2 +- src/main/resources/messages_ar_AR.properties | 33 +++++---- src/main/resources/messages_ca_CA.properties | 31 +++++---- src/main/resources/messages_de_DE.properties | 70 ++++++-------------- src/main/resources/messages_en_US.properties | 33 +++++---- src/main/resources/messages_es_ES.properties | 33 +++++---- src/main/resources/messages_eu_ES.properties | 35 +++++----- src/main/resources/messages_fr_FR.properties | 37 ++++++++--- src/main/resources/messages_it_IT.properties | 33 +++++---- src/main/resources/messages_ja_JP.properties | 33 +++++---- src/main/resources/messages_ko_KR.properties | 33 +++++---- src/main/resources/messages_nl_NL.properties | 33 +++++---- src/main/resources/messages_pl_PL.properties | 33 +++++---- src/main/resources/messages_pt_BR.properties | 33 +++++---- src/main/resources/messages_ro_RO.properties | 33 +++++---- src/main/resources/messages_ru_RU.properties | 33 +++++---- src/main/resources/messages_sv_SE.properties | 33 +++++---- src/main/resources/messages_zh_CN.properties | 33 +++++---- 19 files changed, 340 insertions(+), 273 deletions(-) diff --git a/README.md b/README.md index ba032a8d..a034eaf2 100644 --- a/README.md +++ b/README.md @@ -173,9 +173,6 @@ The Current list of settings is ``` security: enableLogin: false # set to 'true' to enable login - initialLogin: - username: 'username' # Specify the initial username for first boot (e.g. 'admin') - password: 'password' # Specify the initial password for first boot (e.g. 'password123') csrfDisabled: true system: @@ -213,11 +210,11 @@ For those wanting to use Stirling-PDFs backend API to link with their own custom ### Prerequisites: - User must have the folder ./configs volumed within docker so that it is retained during updates. - Docker uses must download the security jar version by setting ``DOCKER_ENABLE_SECURITY`` to ``true`` in environment variables. -- Now the initial user must be generated. Navigate to your settings.yaml and configure your security settings along with the username and password (only required on the first boot to create the initial user, ignored after.). Alternatively, you can set these via the environment variables ``SECURITY_ENABLELOGIN : true`` ``SECURITY_INITIALLOGIN_USERNAME: username`` ``SECURITY_INITIALLOGIN_PASSWORD: password`` +- Now the initial user will be generated with username ``admin`` and password ``stirling``. On login you will be forced to change the password to a new one. Once the above has been done, on restart, a new stirling-pdf-DB.mv.db will show if everything worked. -When you login to Stirling PDF you will be redirected to /login page to login with those credentials. After login everything should function as normal +When you login to Stirling PDF you will be redirected to /login page to login with those default credentials. After login everything should function as normal To access your account settings go to Account settings in the settings cog menu (top right in navbar) This Account settings menu is also where you find your API key. @@ -232,7 +229,7 @@ For API usage you must provide a header with 'X-API-Key' and the associated API - Progress bar/Tracking - Full custom logic pipelines to combine multiple operations together. - Folder support with auto scanning to perform operations on -- Redact text (Via UI) +- Redact text (Via UI not just automated way) - Add Forms - Annotations - Multi page layout (Stich PDF pages together) support x rows y columns and custom page sizing diff --git a/build.gradle b/build.gradle index bc62189e..e528ec1c 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { } group = 'stirling.software' -version = '0.13.1' +version = '0.14.0' sourceCompatibility = '17' repositories { diff --git a/src/main/resources/messages_ar_AR.properties b/src/main/resources/messages_ar_AR.properties index 54e816e6..a4d97973 100644 --- a/src/main/resources/messages_ar_AR.properties +++ b/src/main/resources/messages_ar_AR.properties @@ -35,9 +35,6 @@ delete=Delete username=Username password=Password welcome=Welcome -########################## -### TODO: Translate ### -########################## property=Property black=Black white=White @@ -46,7 +43,11 @@ green=Green blue=Blue custom=Custom... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=\u0645\u0644\u0641\u0627\u062A \u0645\u0636\u063A\u0648\u0 settings.signOut=Sign Out settings.accountSettings=Account Settings + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Account Settings account.accountSettings=Account Settings account.adminSettings=Admin Settings - View and Add Users @@ -105,6 +119,7 @@ adminUserSettings.role=Role adminUserSettings.actions=Actions adminUserSettings.apiUser=Limited API User adminUserSettings.webOnlyUser=Web Only User +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Save User ############# @@ -333,9 +348,6 @@ login.signinTitle=Please sign in #auto-redact autoRedact.title=Auto Redact autoRedact.header=Auto Redact -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Colour autoRedact.textsToRedactLabel=Text to Redact (line-separated) autoRedact.textsToRedactPlaceholder=e.g. \nConfidential \nTop-Secret @@ -756,13 +768,6 @@ changeMetadata.selectText.5=\u0625\u0636\u0627\u0641\u0629 \u0625\u062F\u062E\u0 changeMetadata.submit=\u062A\u063A\u064A\u064A\u0631 -#xlsToPdf -xlsToPdf.title=\u062A\u062D\u0648\u064A\u0644 Excel \u0625\u0644\u0649 PDF -xlsToPdf.header=\u062A\u062D\u0648\u064A\u0644 Excel \u0625\u0644\u0649 PDF -xlsToPdf.selectText.1=\u062D\u062F\u062F \u0648\u0631\u0642\u0629 \u0625\u0643\u0633\u0644 XLS \u0623\u0648 XLSX \u0644\u0644\u062A\u062D\u0648\u064A\u0644 -xlsToPdf.convert=\u062A\u062D\u0648\u064A\u0644 - - #pdfToPDFA pdfToPDFA.title=PDF \u0625\u0644\u0649 PDF / A pdfToPDFA.header=PDF \u0625\u0644\u0649 PDF / A diff --git a/src/main/resources/messages_ca_CA.properties b/src/main/resources/messages_ca_CA.properties index 23aaabb6..d4141c67 100644 --- a/src/main/resources/messages_ca_CA.properties +++ b/src/main/resources/messages_ca_CA.properties @@ -35,7 +35,6 @@ delete=Esborra username=Usuari password=Contrasenya welcome=Benvingut - property=Propietat black=Negre white=Blanc @@ -44,7 +43,11 @@ green=Verd blue=Blau custom=Personalitzat... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -72,6 +75,19 @@ settings.zipThreshold=Comprimiu els fitxers quan el nombre de fitxers baixats su settings.signOut=Sortir settings.accountSettings=Account Settings + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Opcions del compte account.accountSettings=Opcions del compte account.adminSettings=Opcions d'Admin - Veure i afegir usuaris @@ -103,6 +119,7 @@ adminUserSettings.role=Rol adminUserSettings.actions=Accions adminUserSettings.apiUser=Usuari amb API limitada adminUserSettings.webOnlyUser=Usuari només WEB +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Desar Usuari ############# @@ -331,9 +348,6 @@ login.signinTitle=Autenticat #auto-redact autoRedact.title=Auto Redact autoRedact.header=Auto Redact -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Colour autoRedact.textsToRedactLabel=Text to Redact (line-separated) autoRedact.textsToRedactPlaceholder=e.g. \nConfidential \nTop-Secret @@ -754,13 +768,6 @@ changeMetadata.selectText.5=Afegir entrada personalizada changeMetadata.submit=Canvia -#xlsToPdf -xlsToPdf.title=Excel a PDF -xlsToPdf.header=Excel a PDF -xlsToPdf.selectText.1=Selecciona arxiu XLS o XLSX a convertir -xlsToPdf.convert=Converteix - - #pdfToPDFA pdfToPDFA.title=PDF a PDF/A pdfToPDFA.header=PDF a PDF/A diff --git a/src/main/resources/messages_de_DE.properties b/src/main/resources/messages_de_DE.properties index a937649b..88fa9ad7 100644 --- a/src/main/resources/messages_de_DE.properties +++ b/src/main/resources/messages_de_DE.properties @@ -4,7 +4,6 @@ # the direction that the language is written (ltr=left to right, rtl = right to left) language.direction=ltr - pdfPrompt=PDF auswählen multiPdfPrompt=PDFs auswählen(2+) multiPdfDropPrompt=Wählen Sie alle gewünschten PDFs aus (oder ziehen Sie sie per Drag & Drop hierhin) @@ -44,6 +43,13 @@ green=Grün blue=Blau custom=benutzerdefiniert... +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. + + ############# # NAVBAR # @@ -55,7 +61,6 @@ navbar.darkmode=Dark Mode navbar.pageOps=Seitenoperationen navbar.settings=Einstellungen - ############# # SETTINGS # ############# @@ -71,11 +76,23 @@ settings.signOut=Abmelden settings.accountSettings=Kontoeinstellungen + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Kontoeinstellungen account.accountSettings=Kontoeinstellungen account.adminSettings=Admin Einstellungen - Benutzer anzeigen und hinzufügen account.userControlSettings=Benutzerkontrolle -account.changeUsername=Benutzername ändern +account.changeUsername=Passwort ändern account.changeUsername=Passwort ändern account.password=Bestätigungspasswort account.oldPassword=Altes Passwort @@ -102,9 +119,9 @@ adminUserSettings.role=Rolle adminUserSettings.actions=Aktion adminUserSettings.apiUser=Eingeschränkter API-Benutzer adminUserSettings.webOnlyUser=Nur Web-Benutzer +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Benutzer speichern - ############# # HOME-PAGE # ############# @@ -115,17 +132,14 @@ home.multiTool.title=PDF-Multitool home.multiTool.desc=Seiten zusammenführen, drehen, neu anordnen und entfernen multiTool.tags=Multi Tool,Multi operation,UI,click drag,front end,client side - home.merge.title=Zusammenführen home.merge.desc=Mehrere PDF-Dateien zu einer einzigen zusammenführen. merge.tags=merge,Page operations,Back end,server side - home.split.title=Aufteilen home.split.desc=PDFs in mehrere Dokumente aufteilen. split.tags=Page operations,divide,Multi Page,cut,server side - home.rotate.title=Drehen home.rotate.desc=Drehen Sie Ihre PDFs ganz einfach. rotate.tags=server side @@ -135,12 +149,10 @@ home.imageToPdf.title=Bild zu PDF home.imageToPdf.desc=Konvertieren Sie ein Bild (PNG, JPEG, GIF) in ein PDF. imageToPdf.tags=conversion,img,jpg,picture,photo - home.pdfToImage.title=PDF zu Bild home.pdfToImage.desc=Konvertieren Sie ein PDF in ein Bild (PNG, JPEG, GIF). pdfToImage.tags=conversion,img,jpg,picture,photo - home.pdfOrganiser.title=Organisieren home.pdfOrganiser.desc=Seiten entfernen und Seitenreihenfolge ändern. pdfOrganiser.tags=duplex,even,odd,sort,move @@ -150,12 +162,10 @@ home.addImage.title=Bild einfügen home.addImage.desc=Fügt ein Bild an eine bestimmte Stelle im PDF ein (in Arbeit). addImage.tags=img,jpg,picture,photo - home.watermark.title=Wasserzeichen hinzufügen home.watermark.desc=Fügen Sie ein eigenes Wasserzeichen zu Ihrem PDF hinzu. watermark.tags=Text,repeating,label,own,copyright,trademark,img,jpg,picture,photo - home.permissions.title=Berechtigungen ändern home.permissions.desc=Die Berechtigungen für Ihr PDF-Dokument verändern. permissions.tags=read,write,edit,print @@ -165,17 +175,14 @@ home.removePages.title=Entfernen home.removePages.desc=Ungewollte Seiten aus dem PDF entfernen. removePages.tags=Remove pages,delete pages - home.addPassword.title=Passwort hinzufügen home.addPassword.desc=Das PDF mit einem Passwort verschlüsseln. addPassword.tags=secure,security - home.removePassword.title=Passwort entfernen home.removePassword.desc=Den Passwortschutz eines PDFs entfernen. removePassword.tags=secure,Decrypt,security,unpassword,delete password - home.compressPdfs.title=Komprimieren home.compressPdfs.desc=PDF komprimieren um die Dateigröße zu reduzieren. compressPdfs.tags=squish,small,tiny @@ -185,12 +192,10 @@ home.changeMetadata.title=Metadaten ändern home.changeMetadata.desc=Ändern/Entfernen/Hinzufügen von Metadaten aus einem PDF-Dokument changeMetadata.tags==Title,author,date,creation,time,publisher,producer,stats - home.fileToPDF.title=Datei in PDF konvertieren home.fileToPDF.desc=Konvertieren Sie nahezu jede Datei in PDF (DOCX, PNG, XLS, PPT, TXT und mehr) fileToPDF.tags=transformation,format,document,picture,slide,text,conversion,office,docs,word,excel,powerpoint - home.ocr.title=Führe OCR auf PDF- und/oder Cleanup-Scans aus home.ocr.desc=Cleanup scannt und erkennt Text aus Bildern in einer PDF-Datei und fügt ihn erneut als Text hinzu. ocr.tags=recognition,text,image,scan,read,identify,detection,editable @@ -200,27 +205,22 @@ home.extractImages.title=Bilder extrahieren home.extractImages.desc=Extrahiert alle Bilder aus einer PDF-Datei und speichert sie als Zip-Archiv extractImages.tags=picture,photo,save,archive,zip,capture,grab - home.pdfToPDFA.title=PDF zu PDF/A konvertieren home.pdfToPDFA.desc=PDF zu PDF/A für Langzeitarchivierung konvertieren pdfToPDFA.tags=archive,long-term,standard,conversion,storage,preservation - home.PDFToWord.title=PDF zu Word home.PDFToWord.desc=PDF in Word-Formate konvertieren (DOC, DOCX und ODT) PDFToWord.tags=doc,docx,odt,word,transformation,format,conversion,office,microsoft,docfile - home.PDFToPresentation.title=PDF zu Präsentation home.PDFToPresentation.desc=PDF in Präsentationsformate konvertieren (PPT, PPTX und ODP) PDFToPresentation.tags=slides,show,office,microsoft - home.PDFToText.title=PDF in Text/RTF home.PDFToText.desc=PDF in Text- oder RTF-Format konvertieren PDFToText.tags=richformat,richtextformat,rich text format - home.PDFToHTML.title=PDF in HTML home.PDFToHTML.desc=PDF in HTML-Format konvertieren PDFToHTML.tags=web content,browser friendly @@ -230,92 +230,74 @@ home.PDFToXML.title=PDF in XML home.PDFToXML.desc=PDF in XML-Format konvertieren PDFToXML.tags=data-extraction,structured-content,interop,transformation,convert - home.ScannerImageSplit.title=Gescannte Fotos erkennen/aufteilen home.ScannerImageSplit.desc=Teilt mehrere Fotos innerhalb eines Fotos/PDF ScannerImageSplit.tags=separate,auto-detect,scans,multi-photo,organize - home.sign.title=Signieren home.sign.desc=Fügt PDF-Signaturen durch Zeichnung, Text oder Bild hinzu sign.tags=authorize,initials,drawn-signature,text-sign,image-signature - home.flatten.title=Abflachen home.flatten.desc=Alle interaktiven Elemente und Formulare aus einem PDF entfernen flatten.tags=static,deactivate,non-interactive,streamline - home.repair.title=Reparatur home.repair.desc=Versucht, ein beschädigtes/kaputtes PDF zu reparieren repair.tags=fix,restore,correction,recover - home.removeBlanks.title=Leere Seiten entfernen home.removeBlanks.desc=Erkennt und entfernt leere Seiten aus einem Dokument removeBlanks.tags=cleanup,streamline,non-content,organize - home.compare.title=Vergleichen home.compare.desc=Vergleicht und zeigt die Unterschiede zwischen zwei PDF-Dokumenten an compare.tags=differentiate,contrast,changes,analysis - home.certSign.title=Mit Zertifikat signieren home.certSign.desc=Ein PDF mit einem Zertifikat/Schlüssel (PEM/P12) signieren certSign.tags=authenticate,PEM,P12,official,encrypt - home.pageLayout.title=Mehrseitiges Layout home.pageLayout.desc=Mehrere Seiten eines PDF zu einer Seite zusammenführen pageLayout.tags=merge,composite,single-view,organize - home.scalePages.title=Seitengröße/Skalierung anpassen home.scalePages.desc=Größe/Skalierung der Seite und/oder des Inhalts ändern scalePages.tags=resize,modify,dimension,adapt - home.pipeline.title=Pipeline (Fortgeschritten) home.pipeline.desc=Mehrere Aktionen auf ein PDF anwenden, definiert durch einen Pipeline Skript pipeline.tags=automate,sequence,scripted,batch-process - home.add-page-numbers.title=Seitenzahlen hinzufügen home.add-page-numbers.desc=Hinzufügen von Seitenzahlen an einer bestimmten Stelle add-page-numbers.tags=paginate,label,organize,index - home.auto-rename.title=PDF automatisch umbenennen home.auto-rename.desc=PDF-Datei anhand von erkannten Kopfzeilen umbenennen auto-rename.tags=auto-detect,header-based,organize,relabel - home.adjust-contrast.title=Farben/Kontrast anpassen home.adjust-contrast.desc=Kontrast, Sättigung und Helligkeit einer PDF anpassen adjust-contrast.tags=color-correction,tune,modify,enhance - home.crop.title=PDF zuschneiden home.crop.desc=PDF zuschneiden um die Größe zu verändern (Text bleibt erhalten!) crop.tags=trim,shrink,edit,shape - home.autoSplitPDF.title=PDF automatisch teilen home.autoSplitPDF.desc=Physisch gescannte PDF anhand von Splitter-Seiten und QR-Codes aufteilen autoSplitPDF.tags=QR-based,separate,scan-segment,organize - home.sanitizePdf.title=PDF Bereinigen home.sanitizePdf.desc=Entfernen von Skripten und anderen Elementen aus PDF-Dateien sanitizePdf.tags=clean,secure,safe,remove-threats - home.URLToPDF.title=URL/Website zu PDF home.URLToPDF.desc=Konvertiert jede http(s)URL zu PDF URLToPDF.tags=web-capture,save-page,web-to-doc,archive - home.HTMLToPDF.title=HTML zu PDF home.HTMLToPDF.desc=Konvertiert jede HTML-Datei oder Zip-Archiv zu PDF HTMLToPDF.tags=markup,web-content,transformation,convert @@ -345,12 +327,10 @@ home.showJS.title=Javascript anzeigen home.showJS.desc=Alle Javascript Funktionen in einer PDF anzeigen showJS.tags=JS - home.autoRedact.title=Automatisch zensieren/schwärzen home.autoRedact.desc=Automatisches zensiertes (Schwärzen) von Text in einer PDF-Datei basierend auf dem eingegebenen Text showJS.tags=JS - ########################### # # # WEB PAGES # @@ -412,6 +392,7 @@ MarkdownToPDF.help=In Arbeit MarkdownToPDF.credit=Verwendet WeasyPrint + #url-to-pdf URLToPDF.title=URL zu PDF URLToPDF.header=URL zu PDF @@ -787,13 +768,6 @@ changeMetadata.selectText.5=Benutzerdefinierten Metadateneintrag hinzufügen changeMetadata.submit=Ändern -#xlsToPdf -xlsToPdf.title=Excel in PDF -xlsToPdf.header=Excel in PDF -xlsToPdf.selectText.1=XLS- oder XLSX-Excel-Tabelle zum Konvertieren auswählen -xlsToPdf.convert=konvertieren - - #pdfToPDFA pdfToPDFA.title=PDF zu PDF/A pdfToPDFA.header=PDF zu PDF/A diff --git a/src/main/resources/messages_en_US.properties b/src/main/resources/messages_en_US.properties index 38807e3d..e80128c9 100644 --- a/src/main/resources/messages_en_US.properties +++ b/src/main/resources/messages_en_US.properties @@ -35,9 +35,6 @@ delete=Delete username=Username password=Password welcome=Welcome -########################## -### TODO: Translate ### -########################## property=Property black=Black white=White @@ -46,7 +43,11 @@ green=Green blue=Blue custom=Custom... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=Zip files when the number of downloaded files exceeds settings.signOut=Sign Out settings.accountSettings=Account Settings + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Account Settings account.accountSettings=Account Settings account.adminSettings=Admin Settings - View and Add Users @@ -105,6 +119,7 @@ adminUserSettings.role=Role adminUserSettings.actions=Actions adminUserSettings.apiUser=Limited API User adminUserSettings.webOnlyUser=Web Only User +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Save User ############# @@ -333,9 +348,6 @@ login.signinTitle=Please sign in #auto-redact autoRedact.title=Auto Redact autoRedact.header=Auto Redact -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Color autoRedact.textsToRedactLabel=Text to Redact (line-separated) autoRedact.textsToRedactPlaceholder=e.g. \nConfidential \nTop-Secret @@ -756,13 +768,6 @@ changeMetadata.selectText.5=Add Custom Metadata Entry changeMetadata.submit=Change -#xlsToPdf -xlsToPdf.title=Excel to PDF -xlsToPdf.header=Excel to PDF -xlsToPdf.selectText.1=Select XLS or XLSX Excel sheet to convert -xlsToPdf.convert=convert - - #pdfToPDFA pdfToPDFA.title=PDF To PDF/A pdfToPDFA.header=PDF To PDF/A diff --git a/src/main/resources/messages_es_ES.properties b/src/main/resources/messages_es_ES.properties index 37edd2cf..370e6859 100644 --- a/src/main/resources/messages_es_ES.properties +++ b/src/main/resources/messages_es_ES.properties @@ -35,9 +35,6 @@ delete=Delete username=Username password=Password welcome=Welcome -########################## -### TODO: Translate ### -########################## property=Property black=Black white=White @@ -46,7 +43,11 @@ green=Green blue=Blue custom=Custom... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=Ficheros ZIP cuando excede el número de ficheros descarga settings.signOut=Sign Out settings.accountSettings=Account Settings + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Account Settings account.accountSettings=Account Settings account.adminSettings=Admin Settings - View and Add Users @@ -105,6 +119,7 @@ adminUserSettings.role=Role adminUserSettings.actions=Actions adminUserSettings.apiUser=Limited API User adminUserSettings.webOnlyUser=Web Only User +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Save User ############# @@ -333,9 +348,6 @@ login.signinTitle=Please sign in #auto-redact autoRedact.title=Auto Redact autoRedact.header=Auto Redact -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Colour autoRedact.textsToRedactLabel=Text to Redact (line-separated) autoRedact.textsToRedactPlaceholder=e.g. \nConfidential \nTop-Secret @@ -756,13 +768,6 @@ changeMetadata.selectText.5=Agregar entrada de metadatos personalizados changeMetadata.submit=Cambiar -#xlsToPdf -xlsToPdf.title=Excel a PDF -xlsToPdf.header=Excel a PDF -xlsToPdf.selectText.1=Seleccionar hoja de cálculo de Excel XLS o XLSX para convertir -xlsToPdf.convert=Convertir - - #pdfToPDFA pdfToPDFA.title=PDF a PDF/A pdfToPDFA.header=PDF a PDF/A diff --git a/src/main/resources/messages_eu_ES.properties b/src/main/resources/messages_eu_ES.properties index f7dab20b..2e2540be 100644 --- a/src/main/resources/messages_eu_ES.properties +++ b/src/main/resources/messages_eu_ES.properties @@ -35,9 +35,6 @@ delete=ezabatu username=Erabiltzaile izena password=Pasahitza welcome=Ongi etorria -########################## -### TODO: Translate ### -########################## property=Propietate black=Beltza white=Txuria @@ -46,7 +43,11 @@ green=Berdea blue=Urdina custom=Pertsonalizatu... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=ZIP fitxategiak deskargatutako fitxategi kopurua gainditze settings.signOut=Saioa itxi settings.accountSettings=Kontuaren ezarpenak + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Kontuaren ezarpenak account.accountSettings=Kontuaren ezarpenak account.adminSettings=Admin ezarpenak - Ikusi eta gehitu Erabiltzaileak @@ -105,6 +119,7 @@ adminUserSettings.role=Rol adminUserSettings.actions=Ekintzak adminUserSettings.apiUser=APIren erabiltzaile mugatua adminUserSettings.webOnlyUser=Web-erabiltzailea bakarrik +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Gorde Erabiltzailea ############# @@ -333,9 +348,6 @@ login.signinTitle=Mesedez, hasi saioa #auto-redact autoRedact.title=Auto Idatzi autoRedact.header=Auto Idatzi -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Kolorea autoRedact.textsToRedactLabel=Idazteko testua (lerro bidez bereizia) autoRedact.textsToRedactPlaceholder=adib. \nKonfidentziala \nTop-Secret @@ -418,7 +430,7 @@ addPageNumbers.selectText.5=Orrialde kopurua addPageNumbers.selectText.6=Testu pertsonalizatua addPageNumbers.customTextDesc=Testu pertsonalizatua addPageNumbers.numberPagesDesc=Zein orri numeratu, lehenetsita 'denak', 1-5 edo 2,5,9 etab onartzen ditu -addPageNumbers.customNumberDesc=Lehenetsoa {n}-ra, '{n} orria {total}-tik', 'Text-{n}', '{filename}-{n}' ere onartzen du +addPageNumbers.customNumberDesc=Lehenetsoa {n}-ra, '{n} orria {total}-tik', 'Text-{n}', '{filename}-{n}' ere onartzen du addPageNumbers.submit=Gehitu orrialde-zenbakiak @@ -756,13 +768,6 @@ changeMetadata.selectText.5=Gehitu metadatu pertsonalizatuen sarrera changeMetadata.submit=Aldatu -#xlsToPdf -xlsToPdf.title=Excela PDF bihurtu -xlsToPdf.header=Excela PDF bihurtu -xlsToPdf.selectText.1=Hautatu Excel XLSren edo XLSXren kalkulu-orria bihurtzeko -xlsToPdf.convert=Bikurtu - - #pdfToPDFA pdfToPDFA.title=PDFa PDF/A bihurtu pdfToPDFA.header=PDFa PDF/A bihurtu diff --git a/src/main/resources/messages_fr_FR.properties b/src/main/resources/messages_fr_FR.properties index fd302f2e..765afae4 100644 --- a/src/main/resources/messages_fr_FR.properties +++ b/src/main/resources/messages_fr_FR.properties @@ -1,7 +1,7 @@ ########### # Generic # ########### -# the direction that the language is written (ltr = left to right, rtl = right to left) +# the direction that the language is written (ltr=left to right, rtl = right to left) language.direction=ltr pdfPrompt=Sélectionnez le(s) PDF @@ -43,7 +43,11 @@ green=Vert blue=Bleu custom=Personnalisé\u2026 - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -71,11 +75,25 @@ settings.zipThreshold=Compresser les fichiers en ZIP lorsque le nombre de fichie settings.signOut=Déconnexion settings.accountSettings=Paramètres du compte + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Paramètres du compte account.accountSettings=Paramètres du compte account.adminSettings=Paramètres d\u2019administration \u2013 Voir et ajouter des utilisateurs account.userControlSettings=Contrôle des paramètres des utilisateurs account.changeUsername=Modifier le nom d\u2019utilisateur +account.changeUsername=Modifier le nom d\u2019utilisateur account.password=Mot de passe de confirmation account.oldPassword=Ancien mot de passe account.newPassword=Nouveau mot de passe @@ -101,6 +119,7 @@ adminUserSettings.role=Rôle adminUserSettings.actions=Actions adminUserSettings.apiUser=Utilisateur API limité adminUserSettings.webOnlyUser=Utilisateur Web uniquement +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Ajouter ############# @@ -306,7 +325,7 @@ PdfToSinglePage.tags=fusionner,merge,une seule page,single page home.showJS.title=Afficher le JavaScript home.showJS.desc=Recherche et affiche tout JavaScript injecté dans un PDF. -showJS.tags=afficher,javascript,js +showJS.tags=caviarder,redact,auto home.autoRedact.title=Caviarder automatiquement home.autoRedact.desc=Caviardez automatiquement les informations sensibles d\u2019un PDF. @@ -538,7 +557,7 @@ ScannerImageSplit.selectText.8=Définit la surface de contour minimale pour une ScannerImageSplit.selectText.9=Taille de la bordure ScannerImageSplit.selectText.10=Définit la taille de la bordure ajoutée et supprimée pour éviter les bordures blanches dans la sortie (par défaut\u00a0: 1). - + #OCR ocr.title=OCR / Nettoyage des numérisations ocr.header=OCR (Reconnaissance optique de caractères) / Nettoyage des numérisations @@ -627,7 +646,7 @@ rotate.selectAngle=Angle de rotation (par multiples de 90\u202fdegrés) rotate.submit=Pivoter -#split +#merge split.title=Diviser split.header=Diviser split.desc.1=Les numéros que vous sélectionnez sont le numéro de page sur lequel vous souhaitez faire une division @@ -642,17 +661,17 @@ split.splitPages=Pages sur lesquelles diviser split.submit=Diviser -#imageToPDF +#merge imageToPDF.title=Image en PDF imageToPDF.header=Image en PDF +imageToPDF.submit=Convertir imageToPDF.selectText.1=Étirer pour adapter imageToPDF.selectText.2=Rotation automatique du PDF imageToPDF.selectText.3=Logique multi-fichiers (uniquement activée si vous travaillez avec plusieurs images) imageToPDF.selectText.4=Fusionner en un seul PDF imageToPDF.selectText.5=Convertir en PDF séparés -imageToPDF.submit=Convertir - - + + #pdfToImage pdfToImage.title=Image en PDF pdfToImage.header=Image en PDF diff --git a/src/main/resources/messages_it_IT.properties b/src/main/resources/messages_it_IT.properties index 4594e9f8..35f2627e 100644 --- a/src/main/resources/messages_it_IT.properties +++ b/src/main/resources/messages_it_IT.properties @@ -35,9 +35,6 @@ delete=Elimina username=Username password=Password welcome=Benvenuto -########################## -### TODO: Translate ### -########################## property=Proprietà black=Nero white=Bianco @@ -46,7 +43,11 @@ green=Verde blue=Blu custom=Personalizzato - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=Comprimi file in .zip quando il numero di download supera settings.signOut=Logout settings.accountSettings=Impostazioni Account + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Impostazioni Account account.accountSettings=Impostazioni Account account.adminSettings=Impostazioni Admin - Aggiungi e Vedi Utenti @@ -105,6 +119,7 @@ adminUserSettings.role=Ruolo adminUserSettings.actions=Azioni adminUserSettings.apiUser=Utente API limitato adminUserSettings.webOnlyUser=Utente solo Web +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Salva utente ############# @@ -333,9 +348,6 @@ login.signinTitle=Per favore accedi #auto-redact autoRedact.title=Redazione automatica autoRedact.header=Redazione automatica -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Colore autoRedact.textsToRedactLabel=Testo da oscurare (separato da righe) autoRedact.textsToRedactPlaceholder=per esempio. \nConfidenziale \nTop-Secret @@ -756,13 +768,6 @@ changeMetadata.selectText.5=Aggiungi proprietà personalizzata: changeMetadata.submit=Cambia Proprietà -#xlsToPdf -xlsToPdf.title=Da Excel a PDF -xlsToPdf.header=Da Excel a PDF -xlsToPdf.selectText.1=Seleziona un foglio XLS o XLSX da convertire -xlsToPdf.convert=Converti - - #pdfToPDFA pdfToPDFA.title=Da PDF a PDF/A pdfToPDFA.header=Da PDF a PDF/A diff --git a/src/main/resources/messages_ja_JP.properties b/src/main/resources/messages_ja_JP.properties index 4a80c08f..9e061f6a 100644 --- a/src/main/resources/messages_ja_JP.properties +++ b/src/main/resources/messages_ja_JP.properties @@ -35,9 +35,6 @@ delete=削除 username=ユーザー名 password=パスワード welcome=ようこそ -########################## -### TODO: Translate ### -########################## property=プロパティ black=黒 white=白 @@ -46,7 +43,11 @@ green=緑 blue=青 custom=カスタム... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=このファイル数を超えたときにファイルを settings.signOut=サインアウト settings.accountSettings=アカウント設定 + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=アカウント設定 account.accountSettings=アカウント設定 account.adminSettings=管理者設定 - ユーザーの表示と追加 @@ -105,6 +119,7 @@ adminUserSettings.role=役割 adminUserSettings.actions=アクション adminUserSettings.apiUser=限定されたAPIユーザー adminUserSettings.webOnlyUser=ウェブ専用ユーザー +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=ユーザーの保存 ############# @@ -333,9 +348,6 @@ login.signinTitle=サインインしてください #auto-redact autoRedact.title=自動塗りつぶし autoRedact.header=自動塗りつぶし -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=カラー autoRedact.textsToRedactLabel=編集するテキスト (line-separated) autoRedact.textsToRedactPlaceholder=例 \n機密 \n極秘 @@ -756,13 +768,6 @@ changeMetadata.selectText.5=カスタムメタデータの追加 changeMetadata.submit=変更 -#xlsToPdf -xlsToPdf.title=ExcelをPDFに変換 -xlsToPdf.header=ExcelをPDFに変換 -xlsToPdf.selectText.1=変換するXLSまたはXLSX Execlシートを選択 -xlsToPdf.convert=変換 - - #pdfToPDFA pdfToPDFA.title=PDFをPDF/Aに変換 pdfToPDFA.header=PDFをPDF/Aに変換 diff --git a/src/main/resources/messages_ko_KR.properties b/src/main/resources/messages_ko_KR.properties index 39471e4a..f25c8fb4 100644 --- a/src/main/resources/messages_ko_KR.properties +++ b/src/main/resources/messages_ko_KR.properties @@ -35,9 +35,6 @@ delete=Delete username=Username password=Password welcome=Welcome -########################## -### TODO: Translate ### -########################## property=Property black=Black white=White @@ -46,7 +43,11 @@ green=Green blue=Blue custom=Custom... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=다운로드한 파일 수가 초과된 경우 파일 압 settings.signOut=Sign Out settings.accountSettings=Account Settings + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Account Settings account.accountSettings=Account Settings account.adminSettings=Admin Settings - View and Add Users @@ -105,6 +119,7 @@ adminUserSettings.role=Role adminUserSettings.actions=Actions adminUserSettings.apiUser=Limited API User adminUserSettings.webOnlyUser=Web Only User +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Save User ############# @@ -333,9 +348,6 @@ login.signinTitle=Please sign in #auto-redact autoRedact.title=Auto Redact autoRedact.header=Auto Redact -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Colour autoRedact.textsToRedactLabel=Text to Redact (line-separated) autoRedact.textsToRedactPlaceholder=e.g. \nConfidential \nTop-Secret @@ -756,13 +768,6 @@ changeMetadata.selectText.5=사용자 정의 메타데이터 항목 추가 changeMetadata.submit=변경 -#xlsToPdf -xlsToPdf.title=Excel to PDF -xlsToPdf.header=Excel을 PDF로 변환 -xlsToPdf.selectText.1=변환할 XLS 또는 XLSX Excel 시트 선택 -xlsToPdf.convert=변환하기 - - #pdfToPDFA pdfToPDFA.title=PDF To PDF/A pdfToPDFA.header=PDF를 PDF/A로 변환 diff --git a/src/main/resources/messages_nl_NL.properties b/src/main/resources/messages_nl_NL.properties index 1043641a..f39c98e3 100644 --- a/src/main/resources/messages_nl_NL.properties +++ b/src/main/resources/messages_nl_NL.properties @@ -35,9 +35,6 @@ delete=Verwijderen username=Gebruikersnaam password=Wachtwoord welcome=Welkom -########################## -### TODO: Translate ### -########################## property=Property black=Black white=White @@ -46,7 +43,11 @@ green=Green blue=Blue custom=Custom... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=Zip bestanden wanneer het aantal gedownloade bestanden ove settings.signOut=Uitloggen settings.accountSettings=Account instellingen + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Account instellingen account.accountSettings=Account instellingen account.adminSettings=Beheerdersinstellingen - Gebruikers bekijken en toevoegen @@ -105,6 +119,7 @@ adminUserSettings.role=Rol adminUserSettings.actions=Acties adminUserSettings.apiUser=Beperkte API gebruiker adminUserSettings.webOnlyUser=Alleen web gebruiker +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Sla gebruiker op ############# @@ -333,9 +348,6 @@ login.signinTitle=Please sign in #auto-redact autoRedact.title=Auto Redact autoRedact.header=Auto Redact -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Colour autoRedact.textsToRedactLabel=Text to Redact (line-separated) autoRedact.textsToRedactPlaceholder=e.g. \nConfidential \nTop-Secret @@ -756,13 +768,6 @@ changeMetadata.selectText.5=Voeg aangepaste metadata-invoer toe changeMetadata.submit=Wijzigen -#xlsToPdf -xlsToPdf.title=Excel naar PDF -xlsToPdf.header=Excel naar PDF -xlsToPdf.selectText.1=Selecteer XLS of XLSX Excel-blad om te converteren -xlsToPdf.convert=Converteren - - #pdfToPDFA pdfToPDFA.title=PDF naar PDF/A pdfToPDFA.header=PDF naar PDF/A diff --git a/src/main/resources/messages_pl_PL.properties b/src/main/resources/messages_pl_PL.properties index 3fa81afb..d2eaa61f 100644 --- a/src/main/resources/messages_pl_PL.properties +++ b/src/main/resources/messages_pl_PL.properties @@ -35,9 +35,6 @@ delete=Delete username=Username password=Password welcome=Welcome -########################## -### TODO: Translate ### -########################## property=Property black=Black white=White @@ -46,7 +43,11 @@ green=Green blue=Blue custom=Custom... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=Spakuj pliki, gdy liczba pobranych plików przekroczy settings.signOut=Sign Out settings.accountSettings=Account Settings + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Account Settings account.accountSettings=Account Settings account.adminSettings=Admin Settings - View and Add Users @@ -105,6 +119,7 @@ adminUserSettings.role=Role adminUserSettings.actions=Actions adminUserSettings.apiUser=Limited API User adminUserSettings.webOnlyUser=Web Only User +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Save User ############# @@ -333,9 +348,6 @@ login.signinTitle=Please sign in #auto-redact autoRedact.title=Auto Redact autoRedact.header=Auto Redact -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Colour autoRedact.textsToRedactLabel=Text to Redact (line-separated) autoRedact.textsToRedactPlaceholder=e.g. \nConfidential \nTop-Secret @@ -756,13 +768,6 @@ changeMetadata.selectText.5=Dodaj niestandardowy wpis w metadanych changeMetadata.submit=Zmień -#xlsToPdf -xlsToPdf.title=Excel na PDF -xlsToPdf.header=Excel na PDF -xlsToPdf.selectText.1=Wybierz arkusz Microsoft Excel XLS lub XLSX do konwersji -xlsToPdf.convert=Konwertuj - - #pdfToPDFA pdfToPDFA.title=PDF na PDF/A pdfToPDFA.header=PDF na PDF/A diff --git a/src/main/resources/messages_pt_BR.properties b/src/main/resources/messages_pt_BR.properties index d1645d3e..1c904be9 100644 --- a/src/main/resources/messages_pt_BR.properties +++ b/src/main/resources/messages_pt_BR.properties @@ -35,9 +35,6 @@ delete=Delete username=Username password=Password welcome=Welcome -########################## -### TODO: Translate ### -########################## property=Property black=Black white=White @@ -46,7 +43,11 @@ green=Green blue=Blue custom=Custom... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=Compactar arquivos quando o número de arquivos baixados e settings.signOut=Sign Out settings.accountSettings=Account Settings + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Account Settings account.accountSettings=Account Settings account.adminSettings=Admin Settings - View and Add Users @@ -105,6 +119,7 @@ adminUserSettings.role=Role adminUserSettings.actions=Actions adminUserSettings.apiUser=Limited API User adminUserSettings.webOnlyUser=Web Only User +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Save User ############# @@ -333,9 +348,6 @@ login.signinTitle=Please sign in #auto-redact autoRedact.title=Auto Redact autoRedact.header=Auto Redact -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Colour autoRedact.textsToRedactLabel=Text to Redact (line-separated) autoRedact.textsToRedactPlaceholder=e.g. \nConfidential \nTop-Secret @@ -756,13 +768,6 @@ changeMetadata.selectText.5=Adicionar Entrada de Metadados Personalizados changeMetadata.submit=Mudar -#xlsToPdf -xlsToPdf.title=Excel para PDF -xlsToPdf.header=Excel para PDF -xlsToPdf.selectText.1=Selecione a Planilha Excel XLS ou XLSX para Converter -xlsToPdf.convert=Converter - - #pdfToPDFA pdfToPDFA.title=PDF para PDF/A pdfToPDFA.header=PDF para PDF/A diff --git a/src/main/resources/messages_ro_RO.properties b/src/main/resources/messages_ro_RO.properties index 98b58a58..6bf5f1d2 100644 --- a/src/main/resources/messages_ro_RO.properties +++ b/src/main/resources/messages_ro_RO.properties @@ -35,9 +35,6 @@ delete=Delete username=Username password=Password welcome=Welcome -########################## -### TODO: Translate ### -########################## property=Property black=Black white=White @@ -46,7 +43,11 @@ green=Green blue=Blue custom=Custom... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=Împachetează fișierele când numărul de fișiere desc settings.signOut=Sign Out settings.accountSettings=Account Settings + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Account Settings account.accountSettings=Account Settings account.adminSettings=Admin Settings - View and Add Users @@ -105,6 +119,7 @@ adminUserSettings.role=Role adminUserSettings.actions=Actions adminUserSettings.apiUser=Limited API User adminUserSettings.webOnlyUser=Web Only User +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Save User ############# @@ -333,9 +348,6 @@ login.signinTitle=Please sign in #auto-redact autoRedact.title=Auto Redact autoRedact.header=Auto Redact -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Colour autoRedact.textsToRedactLabel=Text to Redact (line-separated) autoRedact.textsToRedactPlaceholder=e.g. \nConfidential \nTop-Secret @@ -756,13 +768,6 @@ changeMetadata.selectText.5=Adăugați Intrare Metadate Personalizate changeMetadata.submit=Schimbare -#xlsToPdf -xlsToPdf.title=Excel to PDF -xlsToPdf.header=Excel to PDF -xlsToPdf.selectText.1=Selectați fișierul Excel XLS sau XLSX pentru a converti -xlsToPdf.convert=convert - - #pdfToPDFA pdfToPDFA.title=PDF către PDF/A pdfToPDFA.header=PDF către PDF/A diff --git a/src/main/resources/messages_ru_RU.properties b/src/main/resources/messages_ru_RU.properties index 08f86f6b..f71192dc 100644 --- a/src/main/resources/messages_ru_RU.properties +++ b/src/main/resources/messages_ru_RU.properties @@ -35,9 +35,6 @@ delete=Delete username=Username password=Password welcome=Welcome -########################## -### TODO: Translate ### -########################## property=Property black=Black white=White @@ -46,7 +43,11 @@ green=Green blue=Blue custom=Custom... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=Zip-файлы, когда количество загру settings.signOut=Sign Out settings.accountSettings=Account Settings + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Account Settings account.accountSettings=Account Settings account.adminSettings=Admin Settings - View and Add Users @@ -105,6 +119,7 @@ adminUserSettings.role=Role adminUserSettings.actions=Actions adminUserSettings.apiUser=Limited API User adminUserSettings.webOnlyUser=Web Only User +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Save User ############# @@ -333,9 +348,6 @@ login.signinTitle=Please sign in #auto-redact autoRedact.title=Auto Redact autoRedact.header=Auto Redact -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Colour autoRedact.textsToRedactLabel=Text to Redact (line-separated) autoRedact.textsToRedactPlaceholder=e.g. \nConfidential \nTop-Secret @@ -756,13 +768,6 @@ changeMetadata.selectText.5=Добавить пользовательскую з changeMetadata.submit=Изменить -#xlsToPdf -xlsToPdf.title=Excel в PDF -xlsToPdf.header=Excel в PDF -xlsToPdf.selectText.1=Выберите книгу Excel XLS или XLSX для преобразования -xlsToPdf.convert=Конвертировать - - #pdfToPDFA pdfToPDFA.title=PDF в PDF/A pdfToPDFA.header=PDF в PDF/A diff --git a/src/main/resources/messages_sv_SE.properties b/src/main/resources/messages_sv_SE.properties index fd3fbfd0..1e69e50b 100644 --- a/src/main/resources/messages_sv_SE.properties +++ b/src/main/resources/messages_sv_SE.properties @@ -35,9 +35,6 @@ delete=Delete username=Username password=Password welcome=Welcome -########################## -### TODO: Translate ### -########################## property=Property black=Black white=White @@ -46,7 +43,11 @@ green=Green blue=Blue custom=Custom... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=Zip-filer när antalet nedladdade filer överskrider settings.signOut=Sign Out settings.accountSettings=Account Settings + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Account Settings account.accountSettings=Account Settings account.adminSettings=Admin Settings - View and Add Users @@ -105,6 +119,7 @@ adminUserSettings.role=Role adminUserSettings.actions=Actions adminUserSettings.apiUser=Limited API User adminUserSettings.webOnlyUser=Web Only User +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Save User ############# @@ -333,9 +348,6 @@ login.signinTitle=Please sign in #auto-redact autoRedact.title=Auto Redact autoRedact.header=Auto Redact -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Colour autoRedact.textsToRedactLabel=Text to Redact (line-separated) autoRedact.textsToRedactPlaceholder=e.g. \nConfidential \nTop-Secret @@ -756,13 +768,6 @@ changeMetadata.selectText.5=Lägg till anpassad metadatapost changeMetadata.submit=Ändra -#xlsToPdf -xlsToPdf.title=Excel till PDF -xlsToPdf.header=Excel till PDF -xlsToPdf.selectText.1=Välj XLS eller XLSX Excel-ark att konvertera -xlsToPdf.convert=konvertera - - #pdfToPDFA pdfToPDFA.title=PDF till PDF/A pdfToPDFA.header=PDF till PDF/A diff --git a/src/main/resources/messages_zh_CN.properties b/src/main/resources/messages_zh_CN.properties index 1eea17a1..c08d7863 100644 --- a/src/main/resources/messages_zh_CN.properties +++ b/src/main/resources/messages_zh_CN.properties @@ -35,9 +35,6 @@ delete=Delete username=Username password=Password welcome=Welcome -########################## -### TODO: Translate ### -########################## property=Property black=Black white=White @@ -46,7 +43,11 @@ green=Green blue=Blue custom=Custom... - +changedCredsMessage=Credentials changed! +notAuthenticatedMessage=User not authenticated. +userNotFoundMessage=User not found. +incorrectPasswordMessage=Current password is incorrect. +usernameExistsMessage=New Username already exists. @@ -74,6 +75,19 @@ settings.zipThreshold=当下载的文件数量超过限制时,将文件压缩 settings.signOut=Sign Out settings.accountSettings=Account Settings + + +changeCreds.title=Change Credentials +changeCreds.header=Update Your Account Details +changeCreds.changeUserAndPassword=You are using default login credentials. Please enter a new password (and username if wanted) +changeCreds.newUsername=New Username +changeCreds.oldPassword=Current Password +changeCreds.newPassword=New Password +changeCreds.confirmNewPassword=Confirm New Password +changeCreds.submit=Submit Changes + + + account.title=Account Settings account.accountSettings=Account Settings account.adminSettings=Admin Settings - View and Add Users @@ -105,6 +119,7 @@ adminUserSettings.role=Role adminUserSettings.actions=Actions adminUserSettings.apiUser=Limited API User adminUserSettings.webOnlyUser=Web Only User +adminUserSettings.forceChange=Force user to change username/password on login adminUserSettings.submit=Save User ############# @@ -333,9 +348,6 @@ login.signinTitle=Please sign in #auto-redact autoRedact.title=Auto Redact autoRedact.header=Auto Redact -########################## -### TODO: Translate ### -########################## autoRedact.colorLabel=Colour autoRedact.textsToRedactLabel=Text to Redact (line-separated) autoRedact.textsToRedactPlaceholder=e.g. \nConfidential \nTop-Secret @@ -756,13 +768,6 @@ changeMetadata.selectText.5=添加自定义元数据条目 changeMetadata.submit=更改 -#xlsToPdf -xlsToPdf.title=Excel转PDF -xlsToPdf.header=Excel转PDF -xlsToPdf.selectText.1=选择要转换的XLS或XLSX Excel表格 -xlsToPdf.convert=转换 - - #pdfToPDFA pdfToPDFA.title=PDF To PDF/A pdfToPDFA.header=PDF to PDF/A From f6c4f08254b699ae798269c65d9b61e1aff5c4ab Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Thu, 14 Sep 2023 13:32:49 +0100 Subject: [PATCH 11/13] docs --- HowToAddNewLanguage.md | 4 +- README.md | 97 ++++++++++++------- .../SPDF/config/CleanUrlInterceptor.java | 1 - src/main/resources/application.properties | 8 ++ src/main/resources/templates/account.html | 2 +- .../resources/templates/change-creds.html | 22 ++++- 6 files changed, 93 insertions(+), 41 deletions(-) diff --git a/HowToAddNewLanguage.md b/HowToAddNewLanguage.md index 26a398bf..b6a7fa4a 100644 --- a/HowToAddNewLanguage.md +++ b/HowToAddNewLanguage.md @@ -8,7 +8,7 @@ Fork Stirling-PDF and make a new branch out of Main Then add reference to the language in the navbar by adding a new language entry to the dropdown -https://github.com/Frooodle/Stirling-PDF/blob/main/src/main/resources/templates/fragments/navbar.html#L306 +https://github.com/Frooodle/Stirling-PDF/blob/main/src/main/resources/templates/fragments/languages.html and add a flag svg file to https://github.com/Frooodle/Stirling-PDF/tree/main/src/main/resources/static/images/flags Any SVG flags are fine, i got most of mine from [here](https://flagicons.lipis.dev/) @@ -25,7 +25,7 @@ The data-language-code is the code used to reference the file in the next step. Start by copying the existing english property file -[https://github.com/Frooodle/Stirling-PDF/tree/langSetup/src/main/resources/messages_en_GB.properties](https://github.com/Frooodle/Stirling-PDF/blob/main/src/main/resources/messages_en_US.properties) +[https://github.com/Frooodle/Stirling-PDF/blob/main/src/main/resources/messages_en_GB.properties](https://github.com/Frooodle/Stirling-PDF/blob/main/src/main/resources/messages_en_GB.properties) Copy and rename it to messages_{your data-language-code here}.properties, in the polish example you would set the name to messages_pl_PL.properties diff --git a/README.md b/README.md index a034eaf2..d0bb6bcc 100644 --- a/README.md +++ b/README.md @@ -21,45 +21,64 @@ Feel free to request any features or bug fixes either in github issues or our [D ![stirling-home](images/stirling-home.png) +## **PDF Features** -## Features -- Full interactive GUI for merging/splitting/rotating/moving PDFs and their pages. -- Split PDFs into multiple files at specified page numbers or extract all pages as individual files. -- Merge multiple PDFs together into a single resultant file -- Convert PDFs to and from images -- Reorganize PDF pages into different orders. -- Add/Generate signatures -- Format PDFs into a multi-paged page -- Scale page contents size by set % -- Adjust Contrast -- Crop PDF -- Auto Split PDF (With physically scanned page dividers) -- Flatten PDFs -- Repair PDFs -- Detect and remove blank pages -- Compare 2 PDFs and show differences in text -- Add images to PDFs -- Rotating PDFs in 90 degree increments. -- Compressing PDFs to decrease their filesize. (Using OCRMyPDF) -- Add and remove passwords -- Set PDF Permissions -- Add watermark(s) -- Convert Any common file to PDF (using LibreOffice) -- Convert PDF to Word/Powerpoint/Others (using LibreOffice) -- Convert HTML to PDF -- URL to PDF -- Extract images from PDF -- Extract images from Scans -- Add page numbers -- Auto rename file by detecting PDF header text -- OCR on PDF (Using OCRMyPDF) -- PDF/A conversion (Using OCRMyPDF) -- Edit metadata +### **Page Operations** +- Full interactive GUI for merging/splitting/rotating/moving PDFs and their pages. +- Merge multiple PDFs together into a single resultant file. +- Split PDFs into multiple files at specified page numbers or extract all pages as individual files. +- Reorganize PDF pages into different orders. +- Rotate PDFs in 90-degree increments. +- Remove pages. +- Multi-page layout (Format PDFs into a multi-paged page). +- Scale page contents size by set %. +- Adjust Contrast. +- Crop PDF. +- Auto Split PDF (With physically scanned page dividers). +- Extract page(s). +- Convert PDF to a single page. + +### **Conversion Operations** +- Convert PDFs to and from images. +- Convert any common file to PDF (using LibreOffice). +- Convert PDF to Word/Powerpoint/Others (using LibreOffice). +- Convert HTML to PDF. +- URL to PDF. +- Markdown to PDF. + +### **Security & Permissions** +- Add and remove passwords. +- Change/set PDF Permissions. +- Add watermark(s). +- Certify/sign PDFs. +- Sanitize PDFs. +- Auto-redact text. + +### **Other Operations** +- Add/Generate/Write signatures. +- Repair PDFs. +- Detect and remove blank pages. +- Compare 2 PDFs and show differences in text. +- Add images to PDFs. +- Compress PDFs to decrease their filesize (Using OCRMyPDF). +- Extract images from PDF. +- Extract images from Scans. +- Add page numbers. +- Auto rename file by detecting PDF header text. +- OCR on PDF (Using OCRMyPDF). +- PDF/A conversion (Using OCRMyPDF). +- Edit metadata. +- Flatten PDFs. +- Get all information on a PDF to view or export as JSON. + +## Extra Features - Dark mode support. - Custom download options (see [here](https://github.com/Frooodle/Stirling-PDF/blob/main/images/settings.png) for example) - Parallel file processing and downloads - API for integration with external scripts + + For a overview of the tasks and the technology each uses please view [groups.md](https://github.com/Frooodle/Stirling-PDF/blob/main/Groups.md) Hosted instance/demo of the app can be seen [here](https://pdf.adminforge.de/) hosted by the team at adminforge.de @@ -94,6 +113,7 @@ docker run -d \ -p 8080:8080 \ -v /location/of/trainingData:/usr/share/tesseract-ocr/4.00/tessdata \ -v /location/of/extraConfigs:/configs \ + -e DOCKER_ENABLE_SECURITY=false \ --name stirling-pdf \ frooodle/s-pdf:latest @@ -114,6 +134,11 @@ services: - /location/of/trainingData:/usr/share/tesseract-ocr/4.00/tessdata #Required for extra OCR languages - /location/of/extraConfigs:/configs # - /location/of/customFiles:/customFiles/ + environment: + - DOCKER_ENABLE_SECURITY=false + + + ``` @@ -122,8 +147,9 @@ services: Please view https://github.com/Frooodle/Stirling-PDF/blob/main/HowToUseOCR.md ## Want to add your own language? -Stirling PDF currently supports 16! +Stirling PDF currently supports 18! - English (English) (en_GB) +- English (US) (en_US) - Arabic (العربية) (ar_AR) - German (Deutsch) (de_DE) - French (Français) (fr_FR) @@ -139,6 +165,7 @@ Stirling PDF currently supports 16! - Russian (Русский) (ru_RU) - Basque (Euskara) (eu_ES) - Japanese (日本語) (ja_JP) +- Dutch (Nederlands) (nl_NL) If you want to add your own language to Stirling-PDF please refer https://github.com/Frooodle/Stirling-PDF/blob/main/HowToAddNewLanguage.md @@ -190,7 +217,7 @@ endpoints: groupsToRemove: [] # List groups to disable (e.g. ['LibreOffice']) metrics: - enabled: true # 'true' to enable Info APIs (`/api/*`) endpoints, 'false' to disable + enabled: true # 'true' to enable Info APIs endpoints (view http://localhost:8080/swagger-ui/index.html#/API to learn more), 'false' to disable ``` ### Extra notes - Endpoints. Currently, the endpoints ENDPOINTS_TO_REMOVE and GROUPS_TO_REMOVE can include comma separate lists of endpoints and groups to disable as example ENDPOINTS_TO_REMOVE=img-to-pdf,remove-pages would disable both image-to-pdf and remove pages, GROUPS_TO_REMOVE=LibreOffice Would disable all things that use LibreOffice. You can see a list of all endpoints and groups [here](https://github.com/Frooodle/Stirling-PDF/blob/main/groups.md) diff --git a/src/main/java/stirling/software/SPDF/config/CleanUrlInterceptor.java b/src/main/java/stirling/software/SPDF/config/CleanUrlInterceptor.java index 4df14253..894d50d8 100644 --- a/src/main/java/stirling/software/SPDF/config/CleanUrlInterceptor.java +++ b/src/main/java/stirling/software/SPDF/config/CleanUrlInterceptor.java @@ -22,7 +22,6 @@ public class CleanUrlInterceptor implements HandlerInterceptor { String queryString = request.getQueryString(); if (queryString != null && !queryString.isEmpty()) { String requestURI = request.getRequestURI(); - Map parameters = new HashMap<>(); // Keep only the allowed parameters diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f5643af8..f8cfc519 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -37,3 +37,11 @@ spring.datasource.username=sa spring.datasource.password= spring.h2.console.enabled=true spring.jpa.hibernate.ddl-auto=update + +# Change the default URL path for OpenAPI JSON +springdoc.api-docs.path=/v1/api-docs + +# Set the URL of the OpenAPI JSON for the Swagger UI +springdoc.swagger-ui.url=/v1/api-docs + + diff --git a/src/main/resources/templates/account.html b/src/main/resources/templates/account.html index b7beed7f..3111c1f0 100644 --- a/src/main/resources/templates/account.html +++ b/src/main/resources/templates/account.html @@ -175,7 +175,7 @@ document.addEventListener("DOMContentLoaded", function() { - const form = document.querySelector('form[action="/change-password"]'); + const form = document.querySelector('form[action="api/v1/user/change-password"]'); form.addEventListener('submit', function(event) { const newPassword = document.getElementById('newPassword').value; diff --git a/src/main/resources/templates/change-creds.html b/src/main/resources/templates/change-creds.html index 5c62fe1d..94b87b64 100644 --- a/src/main/resources/templates/change-creds.html +++ b/src/main/resources/templates/change-creds.html @@ -37,7 +37,7 @@

    Change Username and password

    - +
    @@ -50,12 +50,30 @@
    +
    + + +
    - +
    From 10126ce9797c1d54e4d5c2a17e0f700a3a51a43a Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Thu, 14 Sep 2023 13:35:33 +0100 Subject: [PATCH 12/13] readme --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d0bb6bcc..f4948bbc 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,15 @@ Feel free to request any features or bug fixes either in github issues or our [D ![stirling-home](images/stirling-home.png) + +## Features +- Dark mode support. +- Custom download options (see [here](https://github.com/Frooodle/Stirling-PDF/blob/main/images/settings.png) for example) +- Parallel file processing and downloads +- API for integration with external scripts +- Optional Login and Authentication support (see [here](https://github.com/Frooodle/Stirling-PDF/tree/main#login-authentication) for documentation) + + ## **PDF Features** ### **Page Operations** @@ -71,13 +80,6 @@ Feel free to request any features or bug fixes either in github issues or our [D - Flatten PDFs. - Get all information on a PDF to view or export as JSON. -## Extra Features -- Dark mode support. -- Custom download options (see [here](https://github.com/Frooodle/Stirling-PDF/blob/main/images/settings.png) for example) -- Parallel file processing and downloads -- API for integration with external scripts - - For a overview of the tasks and the technology each uses please view [groups.md](https://github.com/Frooodle/Stirling-PDF/blob/main/Groups.md) Hosted instance/demo of the app can be seen [here](https://pdf.adminforge.de/) hosted by the team at adminforge.de From cd5bd92a4128706b0af4e8a3dea50048b04f8f55 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Thu, 14 Sep 2023 14:30:39 +0100 Subject: [PATCH 13/13] docs --- README.md | 4 ---- .../SPDF/controller/api/security/SanitizeController.java | 2 ++ .../software/SPDF/controller/web/OtherWebController.java | 2 +- src/main/resources/messages_en_GB.properties | 2 +- src/main/resources/messages_en_US.properties | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f4948bbc..4c430e0d 100644 --- a/README.md +++ b/README.md @@ -138,10 +138,6 @@ services: # - /location/of/customFiles:/customFiles/ environment: - DOCKER_ENABLE_SECURITY=false - - - - ``` diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java index 206a65b4..dab9d1d7 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/SanitizeController.java @@ -27,11 +27,13 @@ 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.security.SanitizePdfRequest; import stirling.software.SPDF.utils.WebResponseUtils; @RestController @RequestMapping("/api/v1/security") +@Tag(name = "Security", description = "Security APIs") public class SanitizeController { @PostMapping(consumes = "multipart/form-data", value = "/sanitize-pdf") diff --git a/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java b/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java index 721ca83d..827523cb 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java @@ -15,7 +15,7 @@ import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.tags.Tag; @Controller -@Tag(name = "Other", description = "Other APIs") +@Tag(name = "Misc", description = "Miscellaneous APIs") public class OtherWebController { @GetMapping("/compress-pdf") @Hidden diff --git a/src/main/resources/messages_en_GB.properties b/src/main/resources/messages_en_GB.properties index 740782cc..7abd7dfb 100644 --- a/src/main/resources/messages_en_GB.properties +++ b/src/main/resources/messages_en_GB.properties @@ -56,7 +56,7 @@ usernameExistsMessage=New Username already exists. ############# navbar.convert=Convert navbar.security=Security -navbar.other=Other +navbar.other=Miscellaneous navbar.darkmode=Dark Mode navbar.pageOps=Page Operations navbar.settings=Settings diff --git a/src/main/resources/messages_en_US.properties b/src/main/resources/messages_en_US.properties index e80128c9..3c8ad9f8 100644 --- a/src/main/resources/messages_en_US.properties +++ b/src/main/resources/messages_en_US.properties @@ -56,7 +56,7 @@ usernameExistsMessage=New Username already exists. ############# navbar.convert=Convert navbar.security=Security -navbar.other=Other +navbar.other=Miscellaneous navbar.darkmode=Dark Mode navbar.pageOps=Page Operations navbar.settings=Settings