swagger clean up and more

This commit is contained in:
Ludy87 2025-05-04 18:36:06 +02:00
parent b8aa9f0cdf
commit 71ab5eadf1
No known key found for this signature in database
GPG Key ID: 92696155E0220F94
48 changed files with 341 additions and 171 deletions

View File

@ -77,7 +77,7 @@ public class FilterController {
public ResponseEntity<byte[]> pageCount(@ModelAttribute PDFComparisonAndCount request)
throws IOException, InterruptedException {
MultipartFile inputFile = request.getFileInput();
String pageCount = request.getPageCount();
int pageCount = request.getPageCount();
String comparator = request.getComparator();
// Load the PDF
PDDocument document = pdfDocumentFactory.load(inputFile);
@ -87,13 +87,13 @@ public class FilterController {
// Perform the comparison
switch (comparator) {
case "Greater":
valid = actualPageCount > Integer.parseInt(pageCount);
valid = actualPageCount > pageCount;
break;
case "Equal":
valid = actualPageCount == Integer.parseInt(pageCount);
valid = actualPageCount == pageCount;
break;
case "Less":
valid = actualPageCount < Integer.parseInt(pageCount);
valid = actualPageCount < pageCount;
break;
default:
throw new IllegalArgumentException("Invalid comparator: " + comparator);
@ -153,7 +153,7 @@ public class FilterController {
public ResponseEntity<byte[]> fileSize(@ModelAttribute FileSizeRequest request)
throws IOException, InterruptedException {
MultipartFile inputFile = request.getFileInput();
String fileSize = request.getFileSize();
long fileSize = request.getFileSize();
String comparator = request.getComparator();
// Get the file size
@ -163,13 +163,13 @@ public class FilterController {
// Perform the comparison
switch (comparator) {
case "Greater":
valid = actualFileSize > Long.parseLong(fileSize);
valid = actualFileSize > fileSize;
break;
case "Equal":
valid = actualFileSize == Long.parseLong(fileSize);
valid = actualFileSize == fileSize;
break;
case "Less":
valid = actualFileSize < Long.parseLong(fileSize);
valid = actualFileSize < fileSize;
break;
default:
throw new IllegalArgumentException("Invalid comparator: " + comparator);

View File

@ -47,7 +47,7 @@ public class AutoRenameController {
public ResponseEntity<byte[]> extractHeader(@ModelAttribute ExtractHeaderRequest request)
throws Exception {
MultipartFile file = request.getFileInput();
Boolean useFirstTextAsFallback = request.isUseFirstTextAsFallback();
boolean useFirstTextAsFallback = Boolean.TRUE.equals(request.getUseFirstTextAsFallback());
PDDocument document = pdfDocumentFactory.load(file);
PDFTextStripper reader =

View File

@ -113,7 +113,7 @@ public class AutoSplitPdfController {
public ResponseEntity<byte[]> autoSplitPdf(@ModelAttribute AutoSplitPdfRequest request)
throws IOException {
MultipartFile file = request.getFileInput();
boolean duplexMode = request.isDuplexMode();
boolean duplexMode = Boolean.TRUE.equals(request.getDuplexMode());
PDDocument document = null;
List<PDDocument> splitDocuments = new ArrayList<>();

View File

@ -18,14 +18,13 @@ 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.RequestMapping;
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.tags.Tag;
import lombok.RequiredArgsConstructor;
@ -57,25 +56,11 @@ public class ExtractImageScansController {
+ " parameters. Users can specify angle threshold, tolerance, minimum area,"
+ " minimum contour area, and border size. Input:PDF Output:IMAGE/ZIP"
+ " Type:SIMO")
public ResponseEntity<byte[]> extractImageScans(
@RequestBody(
description = "Form data containing file and extraction parameters",
required = true,
content =
@Content(
mediaType = "multipart/form-data",
schema =
@Schema(
implementation =
ExtractImageScansRequest
.class) // This should
// represent
// your form's
// structure
))
ExtractImageScansRequest form)
public ResponseEntity<byte[]> extractImageScans(@ModelAttribute ExtractImageScansRequest form)
throws IOException, InterruptedException {
String fileName = form.getFileInput().getOriginalFilename();
MultipartFile inputFile = form.getFileInput();
String fileName = inputFile.getOriginalFilename();
String extension = fileName.substring(fileName.lastIndexOf(".") + 1);
List<String> images = new ArrayList<>();
@ -94,7 +79,7 @@ public class ExtractImageScansController {
// Check if input file is a PDF
if ("pdf".equalsIgnoreCase(extension)) {
// Load PDF document
try (PDDocument document = pdfDocumentFactory.load(form.getFileInput())) {
try (PDDocument document = pdfDocumentFactory.load(inputFile)) {
PDFRenderer pdfRenderer = new PDFRenderer(document);
pdfRenderer.setSubsamplingAllowed(true);
int pageCount = document.getNumberOfPages();
@ -116,7 +101,7 @@ public class ExtractImageScansController {
}
} else {
tempInputFile = Files.createTempFile("input_", "." + extension);
form.getFileInput().transferTo(tempInputFile);
inputFile.transferTo(tempInputFile);
// Add input file path to images list
images.add(tempInputFile.toString());
}

View File

@ -64,7 +64,7 @@ public class ExtractImagesController {
throws IOException, InterruptedException, ExecutionException {
MultipartFile file = request.getFileInput();
String format = request.getFormat();
boolean allowDuplicates = request.isAllowDuplicates();
boolean allowDuplicates = Boolean.TRUE.equals(request.getAllowDuplicates());
PDDocument document = pdfDocumentFactory.load(file);
// Determine if multithreading should be used based on PDF size or number of pages

View File

@ -49,33 +49,30 @@ public class PageNumbersController {
MultipartFile file = request.getFileInput();
String customMargin = request.getCustomMargin();
int position = request.getPosition();
int startingNumber = request.getStartingNumber();
int pageNumber = request.getStartingNumber();
String pagesToNumber = request.getPagesToNumber();
String customText = request.getCustomText();
int pageNumber = startingNumber;
float fontSize = request.getFontSize();
String fontType = request.getFontType();
PDDocument document = pdfDocumentFactory.load(file);
float font_size = request.getFontSize();
String font_type = request.getFontType();
float marginFactor;
switch (customMargin.toLowerCase()) {
case "small":
marginFactor = 0.02f;
break;
case "medium":
marginFactor = 0.035f;
break;
case "large":
marginFactor = 0.05f;
break;
case "x-large":
marginFactor = 0.075f;
break;
case "medium":
default:
marginFactor = 0.035f;
break;
}
float fontSize = font_size;
if (pagesToNumber == null || pagesToNumber.isEmpty()) {
pagesToNumber = "all";
}
@ -99,7 +96,7 @@ public class PageNumbersController {
.replaceFirst("[.][^.]+$", ""));
PDType1Font currentFont =
switch (font_type.toLowerCase()) {
switch (fontType.toLowerCase()) {
case "courier" -> new PDType1Font(Standard14Fonts.FontName.COURIER);
case "times" -> new PDType1Font(Standard14Fonts.FontName.TIMES_ROMAN);
default -> new PDType1Font(Standard14Fonts.FontName.HELVETICA);

View File

@ -11,6 +11,9 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode
public class GeneralFile {
@Schema(description = "The input file")
@Schema(
description = "The input file",
requiredMode = Schema.RequiredMode.REQUIRED,
format = "binary")
private MultipartFile fileInput;
}

View File

@ -11,9 +11,12 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode
public class HandleDataRequest {
@Schema(description = "The input files")
@Schema(description = "The input files", requiredMode = Schema.RequiredMode.REQUIRED)
private MultipartFile[] fileInput;
@Schema(description = "JSON String")
@Schema(
description = "JSON String",
defaultValue = "{}",
requiredMode = Schema.RequiredMode.REQUIRED)
private String json;
}

View File

@ -10,6 +10,9 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode
public class ImageFile {
@Schema(description = "The input image file")
@Schema(
description = "The input image file",
requiredMode = Schema.RequiredMode.REQUIRED,
format = "binary")
private MultipartFile fileInput;
}

View File

@ -10,6 +10,6 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode
public class MultiplePDFFiles {
@Schema(description = "The input PDF files", type = "array", format = "binary")
@Schema(description = "The input PDF files", requiredMode = Schema.RequiredMode.REQUIRED)
private MultipartFile[] fileInput;
}

View File

@ -11,6 +11,7 @@ public class PDFComparison extends PDFFile {
@Schema(
description = "The comparison type, accepts Greater, Equal, Less than",
allowableValues = {"Greater", "Equal", "Less"})
allowableValues = {"Greater", "Equal", "Less"},
requiredMode = Schema.RequiredMode.REQUIRED)
private String comparator;
}

View File

@ -8,6 +8,6 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class PDFComparisonAndCount extends PDFComparison {
@Schema(description = "Count")
private String pageCount;
@Schema(description = "Count", requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "0")
private int pageCount;
}

View File

@ -11,6 +11,8 @@ public class PDFExtractImagesRequest extends PDFWithImageFormatRequest {
@Schema(
description =
"Boolean to enable/disable the saving of duplicate images, true to enable duplicates")
private boolean allowDuplicates;
"Boolean to enable/disable the saving of duplicate images, true to enable"
+ " duplicates",
defaultValue = "false")
private Boolean allowDuplicates;
}

View File

@ -12,6 +12,9 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@EqualsAndHashCode
public class PDFFile {
@Schema(description = "The input PDF file", format = "binary")
@Schema(
description = "The input PDF file",
requiredMode = Schema.RequiredMode.REQUIRED,
format = "binary")
private MultipartFile fileInput;
}

View File

@ -11,6 +11,8 @@ public class PDFWithImageFormatRequest extends PDFFile {
@Schema(
description = "The output image format e.g., 'png', 'jpeg', or 'gif'",
allowableValues = {"png", "jpeg", "gif"})
allowableValues = {"png", "jpeg", "gif"},
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "png")
private String format;
}

View File

@ -21,9 +21,9 @@ public class PDFWithPageNums extends PDFFile {
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')\"",
+ " constant (e.g., '2n+1', '3n', '6n-5')",
defaultValue = "all",
requiredMode = RequiredMode.NOT_REQUIRED)
requiredMode = RequiredMode.REQUIRED)
private String pageNumbers;
@Hidden

View File

@ -5,11 +5,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.PDFWithPageNums;
@Data
@EqualsAndHashCode(callSuper = true)
public class ConvertToImageRequest extends PDFFile {
public class ConvertToImageRequest extends PDFWithPageNums {
@Schema(
description = "The output image format",
@ -18,15 +18,11 @@ public class ConvertToImageRequest extends PDFFile {
@Schema(
description =
"Choose between a single image containing all pages or separate images for each page",
"Choose between a single image containing all pages or separate images for each"
+ " page",
allowableValues = {"single", "multiple"})
private String singleOrMultiple;
@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;
@Schema(
description = "The color type of the output image(s)",
allowableValues = {"color", "greyscale", "blackwhite"})

View File

@ -11,7 +11,9 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode
public class ConvertToPdfRequest {
@Schema(description = "The input images to be converted to a PDF file")
@Schema(
description = "The input images to be converted to a PDF file",
requiredMode = Schema.RequiredMode.REQUIRED)
private MultipartFile[] fileInput;
@Schema(

View File

@ -11,6 +11,9 @@ import stirling.software.SPDF.model.api.PDFWithPageNums;
@EqualsAndHashCode(callSuper = true)
public class ContainsTextRequest extends PDFWithPageNums {
@Schema(description = "The text to check for", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(
description = "The text to check for",
defaultValue = "text",
requiredMode = Schema.RequiredMode.REQUIRED)
private String text;
}

View File

@ -11,6 +11,9 @@ import stirling.software.SPDF.model.api.PDFComparison;
@EqualsAndHashCode(callSuper = true)
public class FileSizeRequest extends PDFComparison {
@Schema(description = "File Size", requiredMode = Schema.RequiredMode.REQUIRED)
private String fileSize;
@Schema(
description = "Size of the file in bytes",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "0")
private long fileSize;
}

View File

@ -11,6 +11,9 @@ import stirling.software.SPDF.model.api.PDFComparison;
@EqualsAndHashCode(callSuper = true)
public class PageRotationRequest extends PDFComparison {
@Schema(description = "Rotation in degrees", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(
description = "Rotation in degrees",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "0")
private int rotation;
}

View File

@ -11,6 +11,9 @@ import stirling.software.SPDF.model.api.PDFComparison;
@EqualsAndHashCode(callSuper = true)
public class PageSizeRequest extends PDFComparison {
@Schema(description = "Standard Page Size", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(
description = "Standard Page Size",
allowableValues = {"A0", "A1", "A2", "A3", "A4", "A5", "A6", "LETTER", "LEGAL"},
requiredMode = Schema.RequiredMode.REQUIRED)
private String standardPageSize;
}

View File

@ -15,21 +15,32 @@ public class OverlayPdfsRequest extends PDFFile {
@Schema(
description =
"An array of PDF files to be used as overlays on the base PDF. The order in these files is applied based on the selected mode.")
"An array of PDF files to be used as overlays on the base PDF. The order in"
+ " these files is applied based on the selected mode.",
requiredMode = Schema.RequiredMode.REQUIRED)
private MultipartFile[] overlayFiles;
@Schema(
description =
"The mode of overlaying: 'SequentialOverlay' for sequential application, 'InterleavedOverlay' for round-robin application, 'FixedRepeatOverlay' for fixed repetition based on provided counts",
"The mode of overlaying: 'SequentialOverlay' for sequential application,"
+ " 'InterleavedOverlay' for round-robin application, 'FixedRepeatOverlay'"
+ " for fixed repetition based on provided counts",
allowableValues = {"SequentialOverlay", "InterleavedOverlay", "FixedRepeatOverlay"},
requiredMode = Schema.RequiredMode.REQUIRED)
private String overlayMode;
@Schema(
description =
"An array of integers specifying the number of times each corresponding overlay file should be applied in the 'FixedRepeatOverlay' mode. This should match the length of the overlayFiles array.",
"An array of integers specifying the number of times each corresponding overlay"
+ " file should be applied in the 'FixedRepeatOverlay' mode. This should"
+ " match the length of the overlayFiles array.",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private int[] counts;
@Schema(description = "Overlay position 0 is Foregound, 1 is Background")
@Schema(
description = "Overlay position 0 is Foregound, 1 is Background",
allowableValues = {"0", "1"},
requiredMode = Schema.RequiredMode.REQUIRED,
type = "integer")
private int overlayPosition;
}

View File

@ -14,6 +14,8 @@ public class RotatePDFRequest extends PDFFile {
@Schema(
description =
"The angle by which to rotate the PDF file. This should be a multiple of 90.",
requiredMode = Schema.RequiredMode.REQUIRED,
allowableValues = "0, 90, 180, 270",
example = "90")
private Integer angle;
}

View File

@ -22,6 +22,7 @@ public class AddPageNumbersRequest extends PDFWithPageNums {
@Schema(
description = "Font size for page numbers",
minimum = "1",
defaultValue = "12",
requiredMode = RequiredMode.REQUIRED)
private float fontSize;
@ -33,15 +34,18 @@ public class AddPageNumbersRequest extends PDFWithPageNums {
@Schema(
description =
"Position: 1-9 representing positions on the page (1=top-left, 5=center, 9=bottom-right)",
minimum = "1",
maximum = "9",
"Position: 1-9 representing positions on the page (1=top-left, 2=top-center,"
+ " 3=top-right, 4=middle-left, 5=middle-center, 6=middle-right,"
+ " 7=bottom-left, 8=bottom-center, 9=bottom-right)",
allowableValues = {"1", "2", "3", "4", "5", "6", "7", "8", "9"},
defaultValue = "8",
requiredMode = RequiredMode.REQUIRED)
private int position;
@Schema(
description = "Starting number for page numbering",
minimum = "1",
defaultValue = "1",
requiredMode = RequiredMode.REQUIRED)
private int startingNumber;
@ -53,7 +57,8 @@ public class AddPageNumbersRequest extends PDFWithPageNums {
@Schema(
description =
"Custom text pattern. Available variables: {n}=current page number, {total}=total pages, {filename}=original filename",
"Custom text pattern. Available variables: {n}=current page number,"
+ " {total}=total pages, {filename}=original filename",
example = "Page {n} of {total}",
defaultValue = "{n}",
requiredMode = RequiredMode.NOT_REQUIRED)

View File

@ -19,51 +19,69 @@ public class AddStampRequest extends PDFWithPageNums {
requiredMode = Schema.RequiredMode.REQUIRED)
private String stampType;
@Schema(description = "The stamp text")
@Schema(description = "The stamp text", defaultValue = "Stirling Software")
private String stampText;
@Schema(description = "The stamp image")
private MultipartFile stampImage;
@Schema(
description = "The selected alphabet",
description = "The selected alphabet of the stamp text",
allowableValues = {"roman", "arabic", "japanese", "korean", "chinese"},
defaultValue = "roman")
private String alphabet = "roman";
@Schema(description = "The font size of the stamp text", example = "30")
private float fontSize = 30;
@Schema(
description = "The font size of the stamp text and image",
defaultValue = "30",
requiredMode = Schema.RequiredMode.REQUIRED)
private float fontSize;
@Schema(description = "The rotation of the stamp in degrees", example = "0")
private float rotation = 0;
@Schema(
description = "The rotation of the stamp in degrees",
defaultValue = "0",
requiredMode = Schema.RequiredMode.REQUIRED)
private float rotation;
@Schema(description = "The opacity of the stamp (0.0 - 1.0)", example = "0.5")
@Schema(
description = "The opacity of the stamp (0.0 - 1.0)",
defaultValue = "0.5",
requiredMode = Schema.RequiredMode.REQUIRED)
private float opacity;
@Schema(
description =
"Position for stamp placement based on a 1-9 grid (1: bottom-left, 2: bottom-center, ..., 9: top-right)",
example = "1")
"Position for stamp placement based on a 1-9 grid (1: bottom-left, 2: bottom-center,"
+ " 3: bottom-right, 4: middle-left, 5: middle-center, 6: middle-right,"
+ " 7: top-left, 8: top-center, 9: top-right)",
allowableValues = {"1", "2", "3", "4", "5", "6", "7", "8", "9"},
defaultValue = "5",
requiredMode = Schema.RequiredMode.REQUIRED)
private int position;
@Schema(
description =
"Override X coordinate for stamp placement. If set, it will override the position-based calculation. Negative value means no override.",
example = "-1")
private float overrideX = -1; // Default to -1 indicating no override
"Override X coordinate for stamp placement. If set, it will override the"
+ " position-based calculation. Negative value means no override.",
defaultValue = "-1",
requiredMode = Schema.RequiredMode.REQUIRED)
private float overrideX; // Default to -1 indicating no override
@Schema(
description =
"Override Y coordinate for stamp placement. If set, it will override the position-based calculation. Negative value means no override.",
example = "-1")
private float overrideY = -1; // Default to -1 indicating no override
"Override Y coordinate for stamp placement. If set, it will override the"
+ " position-based calculation. Negative value means no override.",
defaultValue = "-1",
requiredMode = Schema.RequiredMode.REQUIRED)
private float overrideY; // Default to -1 indicating no override
@Schema(
description = "Specifies the margin size for the stamp.",
allowableValues = {"small", "medium", "large", "x-large"},
defaultValue = "medium")
private String customMargin = "medium";
defaultValue = "medium",
requiredMode = Schema.RequiredMode.REQUIRED)
private String customMargin;
@Schema(description = "The color for stamp", defaultValue = "#d3d3d3")
private String customColor = "#d3d3d3";
@Schema(description = "The color of the stamp text", defaultValue = "#d3d3d3")
private String customColor;
}

View File

@ -16,5 +16,5 @@ public class AutoSplitPdfRequest extends PDFFile {
"Flag indicating if the duplex mode is active, where the page after the divider also gets removed.",
requiredMode = Schema.RequiredMode.NOT_REQUIRED,
defaultValue = "false")
private boolean duplexMode;
private Boolean duplexMode;
}

View File

@ -16,5 +16,5 @@ public class ExtractHeaderRequest extends PDFFile {
"Flag indicating whether to use the first text as a fallback if no suitable title is found. Defaults to false.",
requiredMode = Schema.RequiredMode.NOT_REQUIRED,
defaultValue = "false")
private boolean useFirstTextAsFallback;
private Boolean useFirstTextAsFallback;
}

View File

@ -12,36 +12,37 @@ import lombok.EqualsAndHashCode;
public class ExtractImageScansRequest {
@Schema(
description = "The input file containing image scans",
requiredMode = Schema.RequiredMode.REQUIRED)
requiredMode = Schema.RequiredMode.REQUIRED,
format = "binary")
private MultipartFile fileInput;
@Schema(
description = "The angle threshold for the image scan extraction",
defaultValue = "5",
example = "5")
private int angleThreshold = 5;
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "5")
private int angleThreshold;
@Schema(
description = "The tolerance for the image scan extraction",
defaultValue = "20",
example = "20")
private int tolerance = 20;
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "20")
private int tolerance;
@Schema(
description = "The minimum area for the image scan extraction",
defaultValue = "8000",
example = "8000")
private int minArea = 8000;
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "8000")
private int minArea;
@Schema(
description = "The minimum contour area for the image scan extraction",
defaultValue = "500",
example = "500")
private int minContourArea = 500;
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "500")
private int minContourArea;
@Schema(
description = "The border size for the image scan extraction",
defaultValue = "1",
example = "1")
private int borderSize = 1;
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "1")
private int borderSize;
}

View File

@ -13,6 +13,9 @@ public class FlattenRequest extends PDFFile {
@Schema(
description =
"True to flatten only the forms, false to flatten full PDF (Convert page to image)")
"True to flatten only the forms, false to flatten full PDF (Convert page to"
+ " image)",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "false")
private Boolean flattenOnlyForms;
}

View File

@ -13,38 +13,72 @@ import stirling.software.SPDF.model.api.PDFFile;
@EqualsAndHashCode(callSuper = true)
public class MetadataRequest extends PDFFile {
@Schema(description = "Delete all metadata if set to true")
@Schema(
description = "Delete all metadata if set to true",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean deleteAll;
@Schema(description = "The author of the document")
@Schema(
description = "The author of the document",
defaultValue = "author",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String author;
@Schema(description = "The creation date of the document (format: yyyy/MM/dd HH:mm:ss)")
@Schema(
description = "The creation date of the document (format: yyyy/MM/dd HH:mm:ss)",
pattern = "yyyy/MM/dd HH:mm:ss",
defaultValue = "2023/10/01 12:00:00",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String creationDate;
@Schema(description = "The creator of the document")
@Schema(
description = "The creator of the document",
defaultValue = "creator",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String creator;
@Schema(description = "The keywords for the document")
@Schema(
description = "The keywords for the document",
defaultValue = "keywords",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String keywords;
@Schema(description = "The modification date of the document (format: yyyy/MM/dd HH:mm:ss)")
@Schema(
description = "The modification date of the document (format: yyyy/MM/dd HH:mm:ss)",
pattern = "yyyy/MM/dd HH:mm:ss",
defaultValue = "2023/10/01 12:00:00",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String modificationDate;
@Schema(description = "The producer of the document")
@Schema(
description = "The producer of the document",
defaultValue = "producer",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String producer;
@Schema(description = "The subject of the document")
@Schema(
description = "The subject of the document",
defaultValue = "subject",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String subject;
@Schema(description = "The title of the document")
@Schema(
description = "The title of the document",
defaultValue = "title",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String title;
@Schema(description = "The trapped status of the document")
@Schema(
description = "The trapped status of the document",
defaultValue = "False",
allowableValues = {"True", "False", "Unknown"},
requiredMode = Schema.RequiredMode.REQUIRED)
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")
"Map list of key and value of custom parameters. Note these must start with"
+ " customKey and customValue if they are non-standard")
private Map<String, String> allRequestParams;
}

View File

@ -13,30 +13,36 @@ 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.",
"The level of optimization to apply to the PDF file. Higher values indicate"
+ " greater compression but may reduce quality.",
defaultValue = "5",
requiredMode = Schema.RequiredMode.REQUIRED,
allowableValues = {"1", "2", "3", "4", "5", "6", "7", "8", "9"})
private Integer optimizeLevel;
@Schema(description = "The expected output size, e.g. '100MB', '25KB', etc.")
@Schema(
description = "The expected output size, e.g. '100MB', '25KB', etc.",
defaultValue = "25KB",
requiredMode = Schema.RequiredMode.REQUIRED)
private String expectedOutputSize;
@Schema(
description = "Whether to linearize the PDF for faster web viewing. Default is false.",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "false")
private Boolean linearize = false;
@Schema(
description =
"Whether to normalize the PDF content for better compatibility. Default is false.",
"Whether to normalize the PDF content for better compatibility. Default is"
+ " false.",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "false")
private Boolean normalize = false;
@Schema(
description = "Whether to convert the PDF to grayscale. Default is false.",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "false")
private Boolean grayscale = false;
public Boolean getGrayscale() {
return grayscale;
}
}

View File

@ -13,21 +13,27 @@ import stirling.software.SPDF.model.api.PDFFile;
@EqualsAndHashCode(callSuper = true)
public class OverlayImageRequest extends PDFFile {
@Schema(description = "The image file to be overlaid onto the PDF.")
@Schema(
description = "The image file to be overlaid onto the PDF.",
requiredMode = Schema.RequiredMode.REQUIRED,
format = "binary")
private MultipartFile imageFile;
@Schema(
description = "The x-coordinate at which to place the top-left corner of the image.",
example = "0")
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "0")
private float x;
@Schema(
description = "The y-coordinate at which to place the top-left corner of the image.",
example = "0")
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "0")
private float y;
@Schema(
description = "Whether to overlay the image onto every page of the PDF.",
example = "false")
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "false")
private boolean everyPage;
}

View File

@ -13,16 +13,21 @@ import stirling.software.SPDF.model.api.PDFFile;
@EqualsAndHashCode(callSuper = true)
public class ProcessPdfWithOcrRequest extends PDFFile {
@Schema(description = "List of languages to use in OCR processing")
@Schema(
description = "List of languages to use in OCR processing, e.g., 'eng', 'deu'",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "[\"eng\"]")
private List<String> languages;
@Schema(
description = "Specify the OCR type, e.g., 'skip-text', 'force-ocr', or 'Normal'",
requiredMode = Schema.RequiredMode.REQUIRED,
allowableValues = {"skip-text", "force-ocr", "Normal"})
private String ocrType;
@Schema(
description = "Specify the OCR render type, either 'hocr' or 'sandwich'",
requiredMode = Schema.RequiredMode.REQUIRED,
allowableValues = {"hocr", "sandwich"},
defaultValue = "hocr")
private String ocrRenderType = "hocr";

View File

@ -13,12 +13,18 @@ public class RemoveBlankPagesRequest extends PDFFile {
@Schema(
description = "The threshold value to determine blank pages",
requiredMode = Schema.RequiredMode.REQUIRED,
example = "10",
minimum = "0",
maximum = "255",
defaultValue = "10")
private int threshold = 10;
@Schema(
description = "The percentage of white color on a page to consider it as blank",
requiredMode = Schema.RequiredMode.REQUIRED,
minimum = "0.1",
maximum = "100",
example = "99.9",
defaultValue = "99.9")
private float whitePercent = 99.9f;

View File

@ -13,12 +13,16 @@ public class ReplaceAndInvertColorRequest extends PDFFile {
@Schema(
description = "Replace and Invert color options of a pdf.",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "HIGH_CONTRAST_COLOR",
allowableValues = {"HIGH_CONTRAST_COLOR", "CUSTOM_COLOR", "FULL_INVERSION"})
private ReplaceAndInvert replaceAndInvertOption;
@Schema(
description =
"If HIGH_CONTRAST_COLOR option selected, then pick the default color option for text and background.",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "WHITE_TEXT_ON_BLACK",
allowableValues = {
"WHITE_TEXT_ON_BLACK",
"BLACK_TEXT_ON_WHITE",

View File

@ -19,7 +19,7 @@ public class AddWatermarkRequest extends PDFFile {
requiredMode = Schema.RequiredMode.REQUIRED)
private String watermarkType;
@Schema(description = "The watermark text")
@Schema(description = "The watermark text", defaultValue = "Stirling Software")
private String watermarkText;
@Schema(description = "The watermark image")
@ -49,6 +49,9 @@ public class AddWatermarkRequest extends PDFFile {
@Schema(description = "The color for watermark", defaultValue = "#d3d3d3")
private String customColor = "#d3d3d3";
@Schema(description = "Convert the redacted PDF to an image", defaultValue = "false")
@Schema(
description = "Convert the redacted PDF to an image",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean convertPDFToImage;
}

View File

@ -12,12 +12,20 @@ import stirling.software.SPDF.model.api.PDFWithPageNums;
@Data
@EqualsAndHashCode(callSuper = true)
public class ManualRedactPdfRequest extends PDFWithPageNums {
@Schema(description = "A list of areas that should be redacted")
@Schema(
description = "A list of areas that should be redacted",
requiredMode = Schema.RequiredMode.REQUIRED)
private List<RedactionArea> redactions;
@Schema(description = "Convert the redacted PDF to an image", defaultValue = "false")
@Schema(
description = "Convert the redacted PDF to an image",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean convertPDFToImage;
@Schema(description = "The color used to fully redact certain pages")
@Schema(
description = "The color used to fully redact certain pages",
defaultValue = "#000000",
requiredMode = Schema.RequiredMode.REQUIRED)
private String pageRedactionColor;
}

View File

@ -13,6 +13,7 @@ public class PDFPasswordRequest extends PDFFile {
@Schema(
description = "The password of the PDF file",
format = "password",
requiredMode = Schema.RequiredMode.REQUIRED)
private String password;
}

View File

@ -14,21 +14,37 @@ public class RedactPdfRequest extends PDFFile {
@Schema(
description = "List of text to redact from the PDF",
type = "string",
defaultValue = "text,text2",
requiredMode = Schema.RequiredMode.REQUIRED)
private String listOfText;
@Schema(description = "Whether to use regex for the listOfText", defaultValue = "false")
@Schema(
description = "Whether to use regex for the listOfText",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean useRegex;
@Schema(description = "Whether to use whole word search", defaultValue = "false")
@Schema(
description = "Whether to use whole word search",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean wholeWordSearch;
@Schema(description = "The color for redaction", defaultValue = "#000000")
@Schema(
description = "The color for redaction",
defaultValue = "#000000",
requiredMode = Schema.RequiredMode.REQUIRED)
private String redactColor = "#000000";
@Schema(description = "Custom padding for redaction", type = "number")
@Schema(
description = "Custom padding for redaction",
type = "number",
requiredMode = Schema.RequiredMode.REQUIRED)
private float customPadding;
@Schema(description = "Convert the redacted PDF to an image", defaultValue = "false")
@Schema(
description = "Convert the redacted PDF to an image",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean convertPDFToImage;
}

View File

@ -11,21 +11,39 @@ import stirling.software.SPDF.model.api.PDFFile;
@EqualsAndHashCode(callSuper = true)
public class SanitizePdfRequest extends PDFFile {
@Schema(description = "Remove JavaScript actions from the PDF", defaultValue = "false")
@Schema(
description = "Remove JavaScript actions from the PDF",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean removeJavaScript;
@Schema(description = "Remove embedded files from the PDF", defaultValue = "false")
@Schema(
description = "Remove embedded files from the PDF",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean removeEmbeddedFiles;
@Schema(description = "Remove XMP metadata from the PDF", defaultValue = "false")
@Schema(
description = "Remove XMP metadata from the PDF",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean removeXMPMetadata;
@Schema(description = "Remove document info metadata from the PDF", defaultValue = "false")
@Schema(
description = "Remove document info metadata from the PDF",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean removeMetadata;
@Schema(description = "Remove links from the PDF", defaultValue = "false")
@Schema(
description = "Remove links from the PDF",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean removeLinks;
@Schema(description = "Remove fonts from the PDF", defaultValue = "false")
@Schema(
description = "Remove fonts from the PDF",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean removeFonts;
}

View File

@ -20,7 +20,8 @@ public class SignPDFWithCertRequest extends PDFFile {
@Schema(
description =
"The private key for the digital certificate (required for PEM type certificates)")
"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)")
@ -32,26 +33,34 @@ public class SignPDFWithCertRequest extends PDFFile {
@Schema(description = "The JKS keystore file (Java Key Store)")
private MultipartFile jksFile;
@Schema(description = "The password for the keystore or the private key")
@Schema(description = "The password for the keystore or the private key", format = "password")
private String password;
@Schema(description = "Whether to visually show the signature in the PDF file")
@Schema(
description = "Whether to visually show the signature in the PDF file",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean showSignature;
@Schema(description = "The reason for signing the PDF")
@Schema(description = "The reason for signing the PDF", defaultValue = "Signed by SPDF")
private String reason;
@Schema(description = "The location where the PDF is signed")
@Schema(description = "The location where the PDF is signed", defaultValue = "SPDF")
private String location;
@Schema(description = "The name of the signer")
@Schema(description = "The name of the signer", defaultValue = "SPDF")
private String name;
@Schema(
description =
"The page number where the signature should be visible. This is required if showSignature is set to true")
"The page number where the signature should be visible. This is required if"
+ " showSignature is set to true",
defaultValue = "1")
private Integer pageNumber;
@Schema(description = "Whether to visually show a signature logo along with the signature")
@Schema(
description = "Whether to visually show a signature logo along with the signature",
defaultValue = "true",
requiredMode = Schema.RequiredMode.REQUIRED)
private boolean showLogo;
}

View File

@ -13,6 +13,8 @@ import stirling.software.SPDF.model.api.PDFFile;
@EqualsAndHashCode(callSuper = true)
public class SignatureValidationRequest extends PDFFile {
@Schema(description = "(Optional) file to compare PDF cert signatures against x.509 format")
@Schema(
description = "(Optional) file to compare PDF cert signatures against x.509 format",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private MultipartFile certFile;
}

View File

@ -9,6 +9,9 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
public class UpdateUserDetails extends UpdateUserUsername {
@Schema(description = "new password for user")
@Schema(
description = "new password for user",
format = "password",
requiredMode = Schema.RequiredMode.REQUIRED)
private String newPassword;
}

View File

@ -9,6 +9,6 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
public class UpdateUserUsername extends UsernameAndPass {
@Schema(description = "new password for user")
@Schema(description = "new username for user")
private String newUsername;
}

View File

@ -9,6 +9,6 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode
public class Username {
@Schema(description = "username of user")
@Schema(description = "username of user", requiredMode = Schema.RequiredMode.REQUIRED)
private String username;
}

View File

@ -9,6 +9,6 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
public class UsernameAndPass extends Username {
@Schema(description = "password of user")
@Schema(description = "password of user", format = "password")
private String password;
}

View File

@ -21,12 +21,12 @@
<div th:replace="~{fragments/common :: fileSelector(name='fileInput', multipleInputsForSingleRequest=false, accept='application/pdf')}"></div>
<div class="mb-3">
<label for="threshold" th:text="#{removeBlanks.threshold}"></label>
<input type="number" class="form-control" id="threshold" name="threshold" value="10">
<input type="number" class="form-control" id="threshold" name="threshold" value="10" min="0" max="255" step="1">
<small id="thresholdHelp" class="form-text text-muted" th:text="#{removeBlanks.thresholdDesc}"></small>
</div>
<div class="mb-3">
<label for="whitePercent" th:text="#{removeBlanks.whitePercent}"></label>
<input type="number" class="form-control" id="whitePercent" name="whitePercent" value="99.9" step="0.1">
<input type="number" class="form-control" id="whitePercent" name="whitePercent" value="99.9" step="0.1" min="0.1" max="100">
<small id="whitePercentHelp" class="form-text text-muted" th:text="#{removeBlanks.whitePercentDesc}"></small>
</div>
<button type="submit" id="submitBtn" class="btn btn-primary" th:text="#{removeBlanks.submit}"></button>