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 a97ae2bb797..f1d3942f41f 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 @@ @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 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 getBasicInfo(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { @@ -47,7 +47,7 @@ public Map getBasicInfo(@ModelAttribute PDFFile file) throws IOE } @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 getDocumentProperties(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { @@ -66,13 +66,13 @@ public Map getDocumentProperties(@ModelAttribute PDFFile file) t } @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> getPageDimensions(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { List> dimensions = new ArrayList<>(); PDPageTree pages = document.getPages(); - + for (PDPage page : pages) { Map pageDim = new HashMap<>(); pageDim.put("width", page.getBBox().getWidth()); @@ -84,13 +84,13 @@ public List> getPageDimensions(@ModelAttribute PDFFile file) } @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 getFormFields(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { Map 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 Map getFormFields(@ModelAttribute PDFFile file) throws IO } @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 getAnnotationInfo(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { @@ -128,7 +128,7 @@ public Map getAnnotationInfo(@ModelAttribute PDFFile file) throw } @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 getFontInfo(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { @@ -148,33 +148,33 @@ public Map getFontInfo(@ModelAttribute PDFFile file) throws IOEx } @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 getSecurityInfo(@ModelAttribute PDFFile file) throws IOException { try (PDDocument document = Loader.loadPDF(file.getFileInput().getBytes())) { Map securityInfo = new HashMap<>(); PDEncryption encryption = document.getEncryption(); - + if (encryption != null) { securityInfo.put("isEncrypted", true); securityInfo.put("keyLength", encryption.getLength()); - + // Get permissions Map 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 + +}