Multi module refactor (#3640)

# Description of Changes

Migrated Stirling PDF to a multi-module structure:

* Introduced new `:stirling-pdf` module
* Moved all the core logic and features of Stirling PDF into
`:stirling-pdf`
* Updated paths of jobs and scripts

---

## Checklist

### General

- [ ] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md)
(if applicable)
- [ ] I have performed a self-review of my own code
- [ ] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### UI Changes (if applicable)

- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing)
for more details.
This commit is contained in:
Dario Ghunney Ware
2025-06-09 12:51:41 +01:00
committed by GitHub
parent baaaa5a0b2
commit c7d6a063d7
921 changed files with 2480 additions and 7648 deletions
@@ -0,0 +1,42 @@
package stirling.software.SPDF.model;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.databind.JsonNode;
public class ApiEndpoint {
private final String name;
private Map<String, JsonNode> parameters;
private final String description;
public ApiEndpoint(String name, JsonNode postNode) {
this.name = name;
this.parameters = new HashMap<>();
postNode.path("parameters")
.forEach(
paramNode -> {
String paramName = paramNode.path("name").asText();
parameters.put(paramName, paramNode);
});
this.description = postNode.path("description").asText();
}
public boolean areParametersValid(Map<String, Object> providedParams) {
for (String requiredParam : parameters.keySet()) {
if (!providedParams.containsKey(requiredParam)) {
return false;
}
}
return true;
}
public String getDescription() {
return description;
}
@Override
public String toString() {
return "ApiEndpoint [name=" + name + ", parameters=" + parameters + "]";
}
}
@@ -0,0 +1,12 @@
package stirling.software.SPDF.model;
import lombok.Data;
@Data
public class Dependency {
private String moduleName;
private String moduleUrl;
private String moduleVersion;
private String moduleLicense;
private String moduleLicenseUrl;
}
@@ -0,0 +1,13 @@
package stirling.software.SPDF.model;
import lombok.Data;
@Data
public class PDFText {
private final int pageIndex;
private final float x1;
private final float y1;
private final float x2;
private final float y2;
private final String text;
}
@@ -0,0 +1,20 @@
package stirling.software.SPDF.model;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class PipelineConfig {
private String name;
@JsonProperty("pipeline")
private List<PipelineOperation> operations;
private String outputDir;
@JsonProperty("outputFileName")
private String outputPattern;
}
@@ -0,0 +1,11 @@
package stirling.software.SPDF.model;
import java.util.Map;
import lombok.Data;
@Data
public class PipelineOperation {
private String operation;
private Map<String, Object> parameters;
}
@@ -0,0 +1,14 @@
package stirling.software.SPDF.model;
import java.util.List;
import org.springframework.core.io.Resource;
import lombok.Data;
@Data
public class PipelineResult {
private List<Resource> outputFiles;
private boolean hasErrors;
private boolean filtersApplied;
}
@@ -0,0 +1,11 @@
package stirling.software.SPDF.model;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class SignatureFile {
private String fileName;
private String category; // "Personal" or "Shared"
}
@@ -0,0 +1,15 @@
package stirling.software.SPDF.model;
public enum SortTypes {
CUSTOM,
REVERSE_ORDER,
DUPLEX_SORT,
BOOKLET_SORT,
SIDE_STITCH_BOOKLET_SORT,
ODD_EVEN_SPLIT,
ODD_EVEN_MERGE,
REMOVE_FIRST,
REMOVE_LAST,
REMOVE_FIRST_AND_LAST,
DUPLICATE
}
@@ -0,0 +1,22 @@
package stirling.software.SPDF.model.api;
import org.springframework.web.multipart.MultipartFile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode
public class HandleDataRequest {
@Schema(description = "The input files", requiredMode = Schema.RequiredMode.REQUIRED)
private MultipartFile[] fileInput;
@Schema(
description = "JSON String",
defaultValue = "{}",
requiredMode = Schema.RequiredMode.REQUIRED)
private String json;
}
@@ -0,0 +1,18 @@
package stirling.software.SPDF.model.api;
import org.springframework.web.multipart.MultipartFile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode
public class ImageFile {
@Schema(
description = "The input image file",
requiredMode = Schema.RequiredMode.REQUIRED,
format = "binary")
private MultipartFile fileInput;
}
@@ -0,0 +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 lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode
public class MultiplePDFFiles {
@Schema(description = "The input PDF files", requiredMode = Schema.RequiredMode.REQUIRED)
private MultipartFile[] fileInput;
}
@@ -0,0 +1,19 @@
package stirling.software.SPDF.model.api;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class PDFComparison extends PDFFile {
@Schema(
description = "The comparison type, accepts Greater, Equal, Less than",
allowableValues = {"Greater", "Equal", "Less"},
requiredMode = Schema.RequiredMode.REQUIRED)
private String comparator;
}
@@ -0,0 +1,13 @@
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 PDFComparisonAndCount extends PDFComparison {
@Schema(description = "Count", requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "0")
private int pageCount;
}
@@ -0,0 +1,18 @@
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 PDFExtractImagesRequest extends PDFWithImageFormatRequest {
@Schema(
description =
"Boolean to enable/disable the saving of duplicate images, true to enable"
+ " duplicates",
defaultValue = "false")
private Boolean allowDuplicates;
}
@@ -0,0 +1,20 @@
package stirling.software.SPDF.model.api;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class PDFWithImageFormatRequest extends PDFFile {
@Schema(
description = "The output image format e.g., 'png', 'jpeg', or 'gif'",
allowableValues = {"png", "jpeg", "gif"},
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "png")
private String format;
}
@@ -0,0 +1,35 @@
package stirling.software.SPDF.model.api;
import java.util.List;
import org.apache.pdfbox.pdmodel.PDDocument;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
import stirling.software.common.util.GeneralUtils;
@Data
@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')",
defaultValue = "all",
requiredMode = RequiredMode.REQUIRED)
private String pageNumbers;
@Hidden
public List<Integer> getPageNumbersList(PDDocument doc, boolean oneBased) {
int pageCount = doc.getNumberOfPages();
return GeneralUtils.parsePageList(pageNumbers, pageCount, oneBased);
}
}
@@ -0,0 +1,21 @@
package stirling.software.SPDF.model.api;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@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, KEEP.",
requiredMode = Schema.RequiredMode.REQUIRED,
allowableValues = {"A0", "A1", "A2", "A3", "A4", "A5", "A6", "LETTER", "LEGAL", "KEEP"})
private String pageSize;
}
@@ -0,0 +1,30 @@
package stirling.software.SPDF.model.api;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = false)
public class SplitPdfByChaptersRequest extends PDFFile {
@Schema(
description = "Whether to include Metadata or not",
defaultValue = "true",
requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean includeMetadata;
@Schema(
description = "Whether to allow duplicates or not",
defaultValue = "true",
requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean allowDuplicates;
@Schema(
description = "Maximum bookmark level required",
minimum = "0",
defaultValue = "2",
requiredMode = Schema.RequiredMode.REQUIRED)
private Integer bookmarkLevel;
}
@@ -0,0 +1,31 @@
package stirling.software.SPDF.model.api;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class SplitPdfBySectionsRequest extends PDFFile {
@Schema(
description = "Number of horizontal divisions for each PDF page",
defaultValue = "0",
minimum = "0",
requiredMode = Schema.RequiredMode.REQUIRED)
private int horizontalDivisions;
@Schema(
description = "Number of vertical divisions for each PDF page",
defaultValue = "1",
minimum = "0",
requiredMode = Schema.RequiredMode.REQUIRED)
private int verticalDivisions;
@Schema(
description = "Merge the split documents into a single PDF",
defaultValue = "true",
requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean merge;
}
@@ -0,0 +1,32 @@
package stirling.software.SPDF.model.api.converters;
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.tags.Tag;
import stirling.software.common.model.api.PDFFile;
import stirling.software.common.util.PDFToFile;
@RestController
@Tag(name = "Convert", description = "Convert APIs")
@RequestMapping("/api/v1/convert")
public class ConvertPDFToMarkdown {
@PostMapping(consumes = "multipart/form-data", value = "/pdf/markdown")
@Operation(
summary = "Convert PDF to Markdown",
description =
"This endpoint converts a PDF file to Markdown format. Input:PDF Output:Markdown Type:SISO")
public ResponseEntity<byte[]> processPdfToMarkdown(@ModelAttribute PDFFile file)
throws Exception {
MultipartFile inputFile = file.getFileInput();
PDFToFile pdfToFile = new PDFToFile();
return pdfToFile.processPdfToMarkdown(inputFile);
}
}
@@ -0,0 +1,41 @@
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.PDFWithPageNums;
@Data
@EqualsAndHashCode(callSuper = true)
public class ConvertToImageRequest extends PDFWithPageNums {
@Schema(
description = "The output image format",
defaultValue = "png",
allowableValues = {"png", "jpeg", "jpg", "gif", "webp"},
requiredMode = Schema.RequiredMode.REQUIRED)
private String imageFormat;
@Schema(
description =
"Choose between a single image containing all pages or separate images for each"
+ " page",
defaultValue = "multiple",
allowableValues = {"single", "multiple"},
requiredMode = Schema.RequiredMode.REQUIRED)
private String singleOrMultiple;
@Schema(
description = "The color type of the output image(s)",
defaultValue = "color",
allowableValues = {"color", "greyscale", "blackwhite"},
requiredMode = Schema.RequiredMode.REQUIRED)
private String colorType;
@Schema(
description = "The DPI (dots per inch) for the output image(s)",
defaultValue = "300",
requiredMode = Schema.RequiredMode.REQUIRED)
private Integer dpi;
}
@@ -0,0 +1,38 @@
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 lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode
public class ConvertToPdfRequest {
@Schema(
description = "The input images to be converted to a PDF file",
requiredMode = Schema.RequiredMode.REQUIRED)
private MultipartFile[] fileInput;
@Schema(
description = "Option to determine how the image will fit onto the page",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "fillPage",
allowableValues = {"fillPage", "fitDocumentToImage", "maintainAspectRatio"})
private String fitOption;
@Schema(
description = "The color type of the output image(s)",
defaultValue = "color",
requiredMode = Schema.RequiredMode.REQUIRED,
allowableValues = {"color", "greyscale", "blackwhite"})
private String colorType;
@Schema(
description = "Whether to automatically rotate the images to better fit the PDF page",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "false")
private Boolean autoRotate;
}
@@ -0,0 +1,21 @@
package stirling.software.SPDF.model.api.converters;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class PdfToBookRequest extends PDFFile {
@Schema(
description = "The output Ebook format",
requiredMode = Schema.RequiredMode.REQUIRED,
allowableValues = {
"epub", "mobi", "azw3", "docx", "rtf", "txt", "html", "lit", "fb2", "pdb", "lrf"
})
private String outputFormat;
}
@@ -0,0 +1,19 @@
package stirling.software.SPDF.model.api.converters;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class PdfToPdfARequest extends PDFFile {
@Schema(
description = "The output PDF/A type",
requiredMode = Schema.RequiredMode.REQUIRED,
allowableValues = {"pdfa", "pdfa-1"})
private String outputFormat;
}
@@ -0,0 +1,19 @@
package stirling.software.SPDF.model.api.converters;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class PdfToPresentationRequest extends PDFFile {
@Schema(
description = "The output Presentation format",
requiredMode = Schema.RequiredMode.REQUIRED,
allowableValues = {"ppt", "pptx", "odp"})
private String outputFormat;
}
@@ -0,0 +1,19 @@
package stirling.software.SPDF.model.api.converters;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class PdfToTextOrRTFRequest extends PDFFile {
@Schema(
description = "The output Text or RTF format",
requiredMode = Schema.RequiredMode.REQUIRED,
allowableValues = {"rtf", "txt"})
private String outputFormat;
}
@@ -0,0 +1,19 @@
package stirling.software.SPDF.model.api.converters;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class PdfToWordRequest extends PDFFile {
@Schema(
description = "The output Word document format",
requiredMode = Schema.RequiredMode.REQUIRED,
allowableValues = {"doc", "docx", "odt"})
private String outputFormat;
}
@@ -0,0 +1,16 @@
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",
requiredMode = Schema.RequiredMode.REQUIRED)
private String urlInput;
}
@@ -0,0 +1,19 @@
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",
defaultValue = "text",
requiredMode = Schema.RequiredMode.REQUIRED)
private String text;
}
@@ -0,0 +1,19 @@
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;
@Data
@EqualsAndHashCode(callSuper = true)
public class FileSizeRequest extends PDFComparison {
@Schema(
description = "Size of the file in bytes",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "0")
private long fileSize;
}
@@ -0,0 +1,19 @@
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;
@Data
@EqualsAndHashCode(callSuper = true)
public class PageRotationRequest extends PDFComparison {
@Schema(
description = "Rotation in degrees",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "0")
private int rotation;
}
@@ -0,0 +1,20 @@
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;
@Data
@EqualsAndHashCode(callSuper = true)
public class PageSizeRequest extends PDFComparison {
@Schema(
description = "Standard Page Size",
allowableValues = {"A0", "A1", "A2", "A3", "A4", "A5", "A6", "LETTER", "LEGAL"},
defaultValue = "A4",
requiredMode = Schema.RequiredMode.REQUIRED)
private String standardPageSize;
}
@@ -0,0 +1,29 @@
package stirling.software.SPDF.model.api.general;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
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;
}
@@ -0,0 +1,24 @@
package stirling.software.SPDF.model.api.general;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.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.",
type = "number",
defaultValue = "2",
requiredMode = Schema.RequiredMode.REQUIRED,
allowableValues = {"2", "3", "4", "9", "16"})
private int pagesPerSheet;
@Schema(description = "Boolean for if you wish to add border around the pages")
private Boolean addBorder;
}
@@ -0,0 +1,35 @@
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.",
allowableValues = {
"orderProvided",
"byFileName",
"byDateModified",
"byDateCreated",
"byPDFTitle"
},
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "orderProvided")
private String sortType = "orderProvided";
@Schema(
description =
"Flag indicating whether to remove certification signatures from the merged"
+ " PDF. If true, all certification signatures will be removed from the"
+ " final merged document.",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "true")
private Boolean removeCertSign;
}
@@ -0,0 +1,46 @@
package stirling.software.SPDF.model.api.general;
import org.springframework.web.multipart.MultipartFile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
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.",
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",
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.",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private int[] counts;
@Schema(
description = "Overlay position 0 is Foregound, 1 is Background",
allowableValues = {"0", "1"},
requiredMode = Schema.RequiredMode.REQUIRED,
type = "number")
private int overlayPosition;
}
@@ -0,0 +1,30 @@
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.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"
+ "CUSTOM: Uses order defined in PageNums "
+ "DUPLICATE: Duplicate pages n times (if Page order defined as 4, then duplicates each page 4 times)"
+ "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"
+ "ODD_EVEN_MERGE: Merges pages and organises them alternately into odd and even 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;
}
@@ -0,0 +1,21 @@
package stirling.software.SPDF.model.api.general;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.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.",
requiredMode = Schema.RequiredMode.REQUIRED,
allowableValues = {"0", "90", "180", "270"},
defaultValue = "90")
private Integer angle;
}
@@ -0,0 +1,22 @@
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.PDFWithPageSize;
@Data
@EqualsAndHashCode(callSuper = true)
public class ScalePagesRequest extends PDFWithPageSize {
@Schema(
minimum = "0",
defaultValue = "1",
requiredMode = Schema.RequiredMode.REQUIRED,
description =
"The scale of the content on the pages of the output PDF. Acceptable values are"
+ " floats.")
private float scaleFactor;
}
@@ -0,0 +1,27 @@
package stirling.software.SPDF.model.api.general;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class SplitPdfBySizeOrCountRequest extends PDFFile {
@Schema(
description =
"Determines the type of split: 0 for size, 1 for page count, 2 for document count",
requiredMode = Schema.RequiredMode.NOT_REQUIRED,
defaultValue = "0")
private int splitType;
@Schema(
description =
"Value for split: size in MB (e.g., '10MB') or number of pages (e.g., '5')",
requiredMode = Schema.RequiredMode.NOT_REQUIRED,
defaultValue = "10MB")
private String splitValue;
}
@@ -0,0 +1,66 @@
package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFWithPageNums;
@Data
@EqualsAndHashCode(callSuper = true)
public class AddPageNumbersRequest extends PDFWithPageNums {
@Schema(
description = "Custom margin: small/medium/large/x-large",
allowableValues = {"small", "medium", "large", "x-large"},
defaultValue = "medium",
requiredMode = RequiredMode.NOT_REQUIRED)
private String customMargin;
@Schema(
description = "Font size for page numbers",
minimum = "1",
defaultValue = "12",
requiredMode = RequiredMode.REQUIRED)
private float fontSize;
@Schema(
description = "Font type for page numbers",
allowableValues = {"helvetica", "courier", "times"},
requiredMode = RequiredMode.REQUIRED)
private String fontType;
@Schema(
description =
"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;
@Schema(
description = "Which pages to number (e.g. '1,3-5,7' or 'all')",
defaultValue = "all",
requiredMode = RequiredMode.NOT_REQUIRED)
private String pagesToNumber;
@Schema(
description =
"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)
private String customText;
}
@@ -0,0 +1,87 @@
package stirling.software.SPDF.model.api.misc;
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.PDFWithPageNums;
@Data
@EqualsAndHashCode(callSuper = true)
public class AddStampRequest extends PDFWithPageNums {
@Schema(
description = "The stamp type (text or image)",
allowableValues = {"text", "image"},
requiredMode = Schema.RequiredMode.REQUIRED)
private String stampType;
@Schema(description = "The stamp text", defaultValue = "Stirling Software")
private String stampText;
@Schema(description = "The stamp image")
private MultipartFile stampImage;
@Schema(
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 and image",
defaultValue = "30",
requiredMode = Schema.RequiredMode.REQUIRED)
private float fontSize;
@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)",
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,"
+ " 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.",
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.",
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",
requiredMode = Schema.RequiredMode.REQUIRED)
private String customMargin;
@Schema(description = "The color of the stamp text", defaultValue = "#d3d3d3")
private String customColor;
}
@@ -0,0 +1,20 @@
package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.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.",
requiredMode = Schema.RequiredMode.NOT_REQUIRED,
defaultValue = "false")
private Boolean duplexMode;
}
@@ -0,0 +1,20 @@
package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.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.",
requiredMode = Schema.RequiredMode.NOT_REQUIRED,
defaultValue = "false")
private Boolean useFirstTextAsFallback;
}
@@ -0,0 +1,48 @@
package stirling.software.SPDF.model.api.misc;
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",
requiredMode = Schema.RequiredMode.REQUIRED,
format = "binary")
private MultipartFile fileInput;
@Schema(
description = "The angle threshold for the image scan extraction",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "5")
private int angleThreshold;
@Schema(
description = "The tolerance for the image scan extraction",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "20")
private int tolerance;
@Schema(
description = "The minimum area for the image scan extraction",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "8000")
private int minArea;
@Schema(
description = "The minimum contour area for the image scan extraction",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "500")
private int minContourArea;
@Schema(
description = "The border size for the image scan extraction",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "1")
private int borderSize;
}
@@ -0,0 +1,126 @@
package stirling.software.SPDF.model.api.misc;
import org.springframework.web.multipart.MultipartFile;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode
public class FakeScanRequest {
public enum Quality {
low,
medium,
high
}
public enum Rotation {
none,
slight,
moderate,
severe
}
public enum Colorspace {
grayscale,
color
}
@Schema(
description = "PDF file to process",
requiredMode = Schema.RequiredMode.REQUIRED,
type = "string",
format = "binary")
@NotNull(message = "File input is required")
private MultipartFile fileInput;
@Schema(description = "Scan quality preset", example = "high")
@NotNull(message = "Quality is required")
private Quality quality = Quality.high;
@Schema(description = "Rotation preset", example = "none")
@NotNull(message = "Rotation is required")
private Rotation rotation = Rotation.slight;
@Schema(description = "Colorspace for output image", example = "grayscale")
private Colorspace colorspace = Colorspace.grayscale;
@Schema(description = "Border thickness in pixels", example = "20")
private int border = 20;
@Schema(description = "Base rotation in degrees", example = "0")
private int rotate = 0;
@Schema(description = "Random rotation variance in degrees", example = "2")
private int rotateVariance = 2;
@Schema(description = "Brightness multiplier (1.0 = no change)", example = "1.0")
private float brightness = 1.0f;
@Schema(description = "Contrast multiplier (1.0 = no change)", example = "1.0")
private float contrast = 1.0f;
@Schema(description = "Blur amount (0 = none, higher = more blur)", example = "1.0")
private float blur = 1.0f;
@Schema(description = "Noise amount (0 = none, higher = more noise)", example = "8.0")
private float noise = 8.0f;
@Schema(description = "Simulate yellowed paper", example = "false")
private boolean yellowish = false;
@Schema(description = "Rendering resolution in DPI", example = "300")
private int resolution = 300;
@Schema(description = "Whether advanced settings are enabled", example = "false")
private boolean advancedEnabled = false;
public boolean isAdvancedEnabled() {
return advancedEnabled;
}
public int getQualityValue() {
return switch (quality) {
case low -> 30;
case medium -> 60;
case high -> 100;
};
}
public int getRotationValue() {
return switch (rotation) {
case none -> 0;
case slight -> 2;
case moderate -> 5;
case severe -> 8;
};
}
public void applyHighQualityPreset() {
this.blur = 0.1f;
this.noise = 1.0f;
this.brightness = 1.02f;
this.contrast = 1.05f;
this.resolution = 600;
}
public void applyMediumQualityPreset() {
this.blur = 0.5f;
this.noise = 3.0f;
this.brightness = 1.05f;
this.contrast = 1.1f;
this.resolution = 300;
}
public void applyLowQualityPreset() {
this.blur = 1.0f;
this.noise = 5.0f;
this.brightness = 1.1f;
this.contrast = 1.2f;
this.resolution = 150;
}
}
@@ -0,0 +1,21 @@
package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class FlattenRequest extends PDFFile {
@Schema(
description =
"True to flatten only the forms, false to flatten full PDF (Convert page to"
+ " image)",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "false")
private Boolean flattenOnlyForms;
}
@@ -0,0 +1,84 @@
package stirling.software.SPDF.model.api.misc;
import java.util.Map;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class MetadataRequest extends PDFFile {
@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",
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)",
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",
defaultValue = "creator",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String creator;
@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)",
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",
defaultValue = "producer",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String producer;
@Schema(
description = "The subject of the document",
defaultValue = "subject",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String subject;
@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",
defaultValue = "False",
allowableValues = {"True", "False", "Unknown"},
requiredMode = Schema.RequiredMode.NOT_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")
private Map<String, String> allRequestParams;
}
@@ -0,0 +1,48 @@
package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.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.",
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.",
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.",
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;
}
@@ -0,0 +1,39 @@
package stirling.software.SPDF.model.api.misc;
import org.springframework.web.multipart.MultipartFile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class OverlayImageRequest extends PDFFile {
@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.",
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.",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "0")
private float y;
@Schema(
description = "Whether to overlay the image onto every page of the PDF.",
requiredMode = Schema.RequiredMode.REQUIRED,
defaultValue = "false")
private Boolean everyPage;
}
@@ -0,0 +1,17 @@
package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class PrintFileRequest extends PDFFile {
@Schema(
description = "Name of printer to match against",
requiredMode = Schema.RequiredMode.REQUIRED)
private String printerName;
}
@@ -0,0 +1,34 @@
package stirling.software.SPDF.model.api.misc;
import java.util.List;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class ProcessPdfWithOcrRequest extends PDFFile {
@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";
}
@@ -0,0 +1,29 @@
package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class RemoveBlankPagesRequest extends PDFFile {
@Schema(
description = "The threshold value to determine blank pages",
requiredMode = Schema.RequiredMode.REQUIRED,
minimum = "0",
maximum = "255",
defaultValue = "10")
private int threshold;
@Schema(
description = "The percentage of white color on a page to consider it as blank",
requiredMode = Schema.RequiredMode.REQUIRED,
minimum = "0.1",
maximum = "100",
defaultValue = "99.9")
private float whitePercent;
}
@@ -0,0 +1,47 @@
package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
import stirling.software.common.model.api.misc.HighContrastColorCombination;
import stirling.software.common.model.api.misc.ReplaceAndInvert;
@Data
@EqualsAndHashCode(callSuper = true)
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",
"YELLOW_TEXT_ON_BLACK",
"GREEN_TEXT_ON_BLACK"
})
private HighContrastColorCombination highContrastColorCombination;
@Schema(
description =
"If CUSTOM_COLOR option selected, then pick the custom color for background. "
+ "Expected color value should be 24bit decimal value of a color")
private String backGroundColor;
@Schema(
description =
"If CUSTOM_COLOR option selected, then pick the custom color for text. "
+ "Expected color value should be 24bit decimal value of a color")
private String textColor;
}
@@ -0,0 +1,62 @@
package stirling.software.SPDF.model.api.security;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.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)",
format = "password")
private String ownerPassword;
@Schema(
description =
"The password to be added to the PDF file (Restricts the opening of the"
+ " document itself.)",
format = "password")
private String password;
@Schema(
description = "The length of the encryption key",
allowableValues = {"40", "128", "256"},
defaultValue = "256",
requiredMode = Schema.RequiredMode.REQUIRED)
private int keyLength = 256;
@Schema(description = "Whether document assembly is prevented", defaultValue = "false")
private Boolean preventAssembly;
@Schema(description = "Whether content extraction is prevented", defaultValue = "false")
private Boolean preventExtractContent;
@Schema(
description = "Whether content extraction for accessibility is prevented",
defaultValue = "false")
private Boolean preventExtractForAccessibility;
@Schema(description = "Whether form filling is prevented", defaultValue = "false")
private Boolean preventFillInForm;
@Schema(description = "Whether document modification is prevented", defaultValue = "false")
private Boolean preventModify;
@Schema(
description = "Whether modification of annotations is prevented",
defaultValue = "false")
private Boolean preventModifyAnnotations;
@Schema(description = "Whether printing of the document is prevented", defaultValue = "false")
private Boolean preventPrinting;
@Schema(description = "Whether faithful printing is prevented", defaultValue = "false")
private Boolean preventPrintingFaithful;
}
@@ -0,0 +1,57 @@
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 lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class AddWatermarkRequest extends PDFFile {
@Schema(
description = "The watermark type (text or image)",
allowableValues = {"text", "image"},
requiredMode = Schema.RequiredMode.REQUIRED)
private String watermarkType;
@Schema(description = "The watermark text", defaultValue = "Stirling Software")
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", defaultValue = "30")
private float fontSize;
@Schema(description = "The rotation of the watermark in degrees", defaultValue = "0")
private float rotation;
@Schema(description = "The opacity of the watermark (0.0 - 1.0)", defaultValue = "0.5")
private float opacity;
@Schema(description = "The width spacer between watermark elements", defaultValue = "50")
private int widthSpacer;
@Schema(description = "The height spacer between watermark elements", defaultValue = "50")
private int heightSpacer;
@Schema(description = "The color for watermark", defaultValue = "#d3d3d3")
private String customColor;
@Schema(
description = "Convert the redacted PDF to an image",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean convertPDFToImage;
}
@@ -0,0 +1,32 @@
package stirling.software.SPDF.model.api.security;
import java.util.List;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFWithPageNums;
import stirling.software.common.model.api.security.RedactionArea;
@Data
@EqualsAndHashCode(callSuper = true)
public class ManualRedactPdfRequest extends PDFWithPageNums {
@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",
requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean convertPDFToImage;
@Schema(
description = "The color used to fully redact certain pages",
defaultValue = "#000000",
requiredMode = Schema.RequiredMode.REQUIRED)
private String pageRedactionColor;
}
@@ -0,0 +1,19 @@
package stirling.software.SPDF.model.api.security;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class PDFPasswordRequest extends PDFFile {
@Schema(
description = "The password of the PDF file",
format = "password",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String password;
}
@@ -0,0 +1,48 @@
package stirling.software.SPDF.model.api.security;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class RedactPdfRequest extends PDFFile {
@Schema(
description = "List of text to redact from the PDF",
defaultValue = "text,text2",
requiredMode = Schema.RequiredMode.REQUIRED)
private String listOfText;
@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",
requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean wholeWordSearch;
@Schema(
description = "The color for redaction",
defaultValue = "#000000",
requiredMode = Schema.RequiredMode.REQUIRED)
private String redactColor;
@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",
requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean convertPDFToImage;
}
@@ -0,0 +1,49 @@
package stirling.software.SPDF.model.api.security;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class SanitizePdfRequest extends PDFFile {
@Schema(
description = "Remove JavaScript actions from the PDF",
defaultValue = "true",
requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean removeJavaScript;
@Schema(
description = "Remove embedded files from the PDF",
defaultValue = "true",
requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean removeEmbeddedFiles;
@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",
requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean removeMetadata;
@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",
requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean removeFonts;
}
@@ -0,0 +1,67 @@
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 lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class SignPDFWithCertRequest extends PDFFile {
@Schema(
description = "The type of the digital certificate",
allowableValues = {"PEM", "PKCS12", "JKS"},
requiredMode = Schema.RequiredMode.REQUIRED)
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 JKS keystore file (Java Key Store)")
private MultipartFile jksFile;
@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",
defaultValue = "false",
requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean showSignature;
@Schema(description = "The reason for signing the PDF", defaultValue = "Signed by SPDF")
private String reason;
@Schema(description = "The location where the PDF is signed", defaultValue = "SPDF")
private String location;
@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",
defaultValue = "1")
private Integer pageNumber;
@Schema(
description = "Whether to visually show a signature logo along with the signature",
defaultValue = "true",
requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean showLogo;
}
@@ -0,0 +1,20 @@
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 lombok.EqualsAndHashCode;
import stirling.software.common.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper = true)
public class SignatureValidationRequest extends PDFFile {
@Schema(
description = "(Optional) file to compare PDF cert signatures against x.509 format",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private MultipartFile certFile;
}
@@ -0,0 +1,30 @@
package stirling.software.SPDF.model.api.security;
import java.util.List;
import lombok.Data;
@Data
public class SignatureValidationResult {
private boolean valid;
private String signerName;
private String signatureDate;
private String reason;
private String location;
private String errorMessage;
private boolean chainValid;
private boolean trustValid;
private boolean notExpired;
private boolean notRevoked;
private String issuerDN; // Certificate issuer's Distinguished Name
private String subjectDN; // Certificate subject's Distinguished Name
private String serialNumber; // Certificate serial number
private String validFrom; // Certificate validity start date
private String validUntil; // Certificate validity end date
private String signatureAlgorithm; // Algorithm used for signing
private int keySize; // Key size in bits
private String version; // Certificate version
private List<String> keyUsages; // List of key usage purposes
private boolean isSelfSigned; // Whether the certificate is self-signed
}