From 3220ad2045fda632309084490339bf26950464ba Mon Sep 17 00:00:00 2001 From: "stirlingbot[bot]" <195170888+stirlingbot[bot]@users.noreply.github.com> Date: Thu, 30 Jan 2025 11:01:35 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20format=20everything=20with=20pre?= =?UTF-8?q?-commit=20by=20<stirlingbot>=20(#2794)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Auto-generated by [create-pull-request][1] with **stirlingbot** [1]: https://github.com/peter-evans/create-pull-request Signed-off-by: stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com> Co-authored-by: stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com> --- .../controller/api/AnalysisController.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/controller/api/AnalysisController.java b/src/main/java/stirling/software/SPDF/controller/api/AnalysisController.java index a97ae2bb..f1d3942f 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/AnalysisController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/AnalysisController.java @@ -23,18 +23,18 @@ import java.util.*; @Tag(name = "Analysis", description = "Analysis APIs") public class AnalysisController { - + @PostMapping(value = "/page-count", consumes = "multipart/form-data") - @Operation(summary = "Get PDF page count", + @Operation(summary = "Get PDF page count", description = "Returns total number of pages in PDF. Input:PDF Output:JSON Type:SISO") public Map<String, Integer> getPageCount(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { return Map.of("pageCount", document.getNumberOfPages()); } } - + @PostMapping(value ="/basic-info", consumes = "multipart/form-data") - @Operation(summary = "Get basic PDF information", + @Operation(summary = "Get basic PDF information", description = "Returns page count, version, file size. Input:PDF Output:JSON Type:SISO") public Map<String, Object> getBasicInfo(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { @@ -47,7 +47,7 @@ public class AnalysisController { } @PostMapping(value ="/document-properties", consumes = "multipart/form-data") - @Operation(summary = "Get PDF document properties", + @Operation(summary = "Get PDF document properties", description = "Returns title, author, subject, etc. Input:PDF Output:JSON Type:SISO") public Map<String, String> getDocumentProperties(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { @@ -66,13 +66,13 @@ public class AnalysisController { } @PostMapping(value ="/page-dimensions", consumes = "multipart/form-data") - @Operation(summary = "Get page dimensions for all pages", + @Operation(summary = "Get page dimensions for all pages", description = "Returns width and height of each page. Input:PDF Output:JSON Type:SISO") public List<Map<String, Float>> getPageDimensions(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { List<Map<String, Float>> dimensions = new ArrayList<>(); PDPageTree pages = document.getPages(); - + for (PDPage page : pages) { Map<String, Float> pageDim = new HashMap<>(); pageDim.put("width", page.getBBox().getWidth()); @@ -84,13 +84,13 @@ public class AnalysisController { } @PostMapping(value ="/form-fields", consumes = "multipart/form-data") - @Operation(summary = "Get form field information", + @Operation(summary = "Get form field information", description = "Returns count and details of form fields. Input:PDF Output:JSON Type:SISO") public Map<String, Object> getFormFields(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { Map<String, Object> formInfo = new HashMap<>(); PDAcroForm form = document.getDocumentCatalog().getAcroForm(); - + if (form != null) { formInfo.put("fieldCount", form.getFields().size()); formInfo.put("hasXFA", form.hasXFA()); @@ -105,7 +105,7 @@ public class AnalysisController { } @PostMapping(value ="/annotation-info", consumes = "multipart/form-data") - @Operation(summary = "Get annotation information", + @Operation(summary = "Get annotation information", description = "Returns count and types of annotations. Input:PDF Output:JSON Type:SISO") public Map<String, Object> getAnnotationInfo(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { @@ -128,7 +128,7 @@ public class AnalysisController { } @PostMapping(value ="/font-info", consumes = "multipart/form-data") - @Operation(summary = "Get font information", + @Operation(summary = "Get font information", description = "Returns list of fonts used in the document. Input:PDF Output:JSON Type:SISO") public Map<String, Object> getFontInfo(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { @@ -148,33 +148,33 @@ public class AnalysisController { } @PostMapping(value ="/security-info", consumes = "multipart/form-data") - @Operation(summary = "Get security information", + @Operation(summary = "Get security information", description = "Returns encryption and permission details. Input:PDF Output:JSON Type:SISO") public Map<String, Object> getSecurityInfo(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { Map<String, Object> securityInfo = new HashMap<>(); PDEncryption encryption = document.getEncryption(); - + if (encryption != null) { securityInfo.put("isEncrypted", true); securityInfo.put("keyLength", encryption.getLength()); - + // Get permissions Map<String, Boolean> permissions = new HashMap<>(); permissions.put("canPrint", document.getCurrentAccessPermission().canPrint()); permissions.put("canModify", document.getCurrentAccessPermission().canModify()); permissions.put("canExtractContent", document.getCurrentAccessPermission().canExtractContent()); permissions.put("canModifyAnnotations", document.getCurrentAccessPermission().canModifyAnnotations()); - + securityInfo.put("permissions", permissions); } else { securityInfo.put("isEncrypted", false); } - + return securityInfo; } } - -} \ No newline at end of file + +}