From 51f863e1e4e89b3d8955e834852f738e47863070 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Thu, 5 Oct 2023 21:20:05 +0100 Subject: [PATCH] swagger docs fix #401 --- .../SPDF/controller/api/RearrangePagesPDFController.java | 8 +++++--- src/main/resources/templates/remove-pages.html | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) 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 9dd607b8..b76b6cee 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java @@ -21,6 +21,7 @@ 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.SortTypes; +import stirling.software.SPDF.model.api.PDFWithPageNums; import stirling.software.SPDF.model.api.general.RearrangePagesRequest; import stirling.software.SPDF.utils.GeneralUtils; import stirling.software.SPDF.utils.WebResponseUtils; @@ -33,11 +34,12 @@ public class RearrangePagesPDFController { @PostMapping(consumes = "multipart/form-data", value = "/remove-pages") @Operation(summary = "Remove pages from a PDF file", description = "This endpoint removes specified pages from a given PDF file. Users can provide a comma-separated list of page numbers or ranges to delete. Input:PDF Output:PDF Type:SISO") - public ResponseEntity deletePages( - @RequestPart(required = true, value = "fileInput") @Parameter(description = "The input PDF file from which pages will be removed") MultipartFile pdfFile, - @RequestParam("pagesToDelete") @Parameter(description = "Comma-separated list of pages or page ranges to delete, e.g., '1,3,5-8'") String pagesToDelete) + public ResponseEntity deletePages(@ModelAttribute PDFWithPageNums request ) throws IOException { + MultipartFile pdfFile = request.getFileInput(); + String pagesToDelete = request.getPageNumbers(); + PDDocument document = PDDocument.load(pdfFile.getBytes()); // Split the page order string into an array of page numbers or range of numbers diff --git a/src/main/resources/templates/remove-pages.html b/src/main/resources/templates/remove-pages.html index 749a1c2f..63c171dd 100644 --- a/src/main/resources/templates/remove-pages.html +++ b/src/main/resources/templates/remove-pages.html @@ -17,8 +17,8 @@
- - + +