Merge branch 'itextRemoval' of git@github.com:Frooodle/Stirling-PDF.git

into itextRemoval
This commit is contained in:
Anthony Stirling 2023-09-11 23:21:05 +01:00
commit 1404e33386
42 changed files with 116 additions and 52 deletions

View file

@ -19,12 +19,11 @@ import org.springframework.web.multipart.MultipartFile;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import stirling.software.SPDF.utils.GeneralUtils;
import stirling.software.SPDF.utils.WebResponseUtils;
import stirling.software.SPDF.model.SortTypes;
import stirling.software.SPDF.model.api.general.RearrangePagesRequest;
import stirling.software.SPDF.utils.GeneralUtils;
import stirling.software.SPDF.utils.WebResponseUtils;
@RestController
@RequestMapping("/api/v1/general")
@Tag(name = "General", description = "General APIs")

View file

@ -21,6 +21,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.Hidden;
@ -51,7 +52,8 @@ public class GeneralWebController {
}
List<Map<String, String>> pipelineConfigsWithNames = new ArrayList<>();
for (String config : pipelineConfigs) {
Map<String, Object> jsonContent = new ObjectMapper().readValue(config, Map.class);
Map<String, Object> jsonContent = new ObjectMapper().readValue(config, new TypeReference<Map<String, Object>>(){});
String name = (String) jsonContent.get("name");
Map<String, String> configWithName = new HashMap<>();
configWithName.put("json", config);

View file

@ -4,8 +4,12 @@ import org.springframework.web.multipart.MultipartFile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@Data
@EqualsAndHashCode
@NoArgsConstructor
public class GeneralFile {
@Schema(description = "The input file")

View file

@ -1,10 +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 org.springframework.web.multipart.MultipartFile;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@EqualsAndHashCode
public class HandleDataRequest {
@Schema(description = "The input files")

View file

@ -4,8 +4,12 @@ import org.springframework.web.multipart.MultipartFile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@EqualsAndHashCode
public class ImageFile {
@Schema(description = "The input image file")
private MultipartFile fileInput;

View file

@ -4,7 +4,11 @@ import org.springframework.web.multipart.MultipartFile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@EqualsAndHashCode
public class MultiplePDFFiles {
@Schema(description = "The input PDF files", type = "array", format = "binary")
private MultipartFile[] fileInput;

View file

@ -1,15 +1,12 @@
package stirling.software.SPDF.model.api;
import java.io.IOException;
import java.util.List;
import org.apache.pdfbox.pdmodel.PDDocument;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import stirling.software.SPDF.utils.GeneralUtils;
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper=true)
public class PDFComparison extends PDFFile {
@Schema(description = "The comparison type, accepts Greater, Equal, Less than", allowableValues = {

View file

@ -1,15 +1,12 @@
package stirling.software.SPDF.model.api;
import java.io.IOException;
import java.util.List;
import org.apache.pdfbox.pdmodel.PDDocument;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import stirling.software.SPDF.utils.GeneralUtils;
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper=true)
public class PDFComparisonAndCount extends PDFComparison {
@Schema(description = "Count")
private String pageCount;

View file

@ -4,7 +4,9 @@ import org.springframework.web.multipart.MultipartFile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode
public class PDFFile {
@Schema(description = "The input PDF file")
private MultipartFile fileInput;

View file

@ -2,8 +2,10 @@ 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 PDFWithImageFormatRequest extends PDFFile {
@Schema(description = "The output image format e.g., 'png', 'jpeg', or 'gif'",

View file

@ -4,12 +4,15 @@ import java.io.IOException;
import java.util.List;
import org.apache.pdfbox.pdmodel.PDDocument;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import stirling.software.SPDF.utils.GeneralUtils;
@Data
@NoArgsConstructor
@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')\"")

View file

@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.converters;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class ConvertToImageRequest extends PDFFile {
@Schema(description = "The output image format", allowableValues = {"png", "jpeg", "jpg", "gif"})

View file

@ -1,10 +1,13 @@
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 org.springframework.web.multipart.MultipartFile;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode
public class ConvertToPdfRequest {
@Schema(description = "The input images to be converted to a PDF file")

View file

@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.converters;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class PdfToPresentationRequest extends PDFFile {
@Schema(description = "The output Presentation format", allowableValues = {"ppt", "pptx", "odp"})

View file

@ -2,9 +2,11 @@ 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.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class PdfToTextOrRTFRequest extends PDFFile {
@Schema(description = "The output Text or RTF format", allowableValues = {"rtf", "txt:Text"})

View file

@ -2,9 +2,11 @@ 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.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class PdfToWordRequest extends PDFFile {
@Schema(description = "The output Word document format", allowableValues = {"doc", "docx", "odt"})

View file

@ -2,8 +2,10 @@ 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", required = true)

View file

@ -2,9 +2,11 @@ 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", required = true)

View file

@ -2,10 +2,11 @@ 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;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class FileSizeRequest extends PDFComparison {
@Schema(description = "File Size", required = true)

View file

@ -2,10 +2,11 @@ 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;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class PageRotationRequest extends PDFComparison {
@Schema(description = "Rotation in degrees", required = true)

View file

@ -2,10 +2,11 @@ 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;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class PageSizeRequest extends PDFComparison {
@Schema(description = "Standard Page Size", required = true)

View file

@ -1,13 +1,11 @@
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.PDFFile;
import org.springframework.web.multipart.MultipartFile;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
@Data
@EqualsAndHashCode(callSuper=true)
public class CropPdfForm extends PDFFile {

View file

@ -2,9 +2,11 @@ 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.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.",

View file

@ -2,9 +2,11 @@ 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.",

View file

@ -2,11 +2,11 @@ package stirling.software.SPDF.model.api.general;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import stirling.software.SPDF.model.api.PDFFile;
import stirling.software.SPDF.model.api.PDFWithPageNums;
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"

View file

@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.general;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.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.", example = "90")

View file

@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.general;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class ScalePagesRequest extends PDFFile {
@Schema(description = "The scale of pages in the output PDF. Acceptable values are A0-A10, B0-B9, LETTER, TABLOID, LEDGER, LEGAL, EXECUTIVE.",

View file

@ -2,11 +2,11 @@ package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFWithPageNums;
import org.springframework.web.multipart.MultipartFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class AddPageNumbersRequest extends PDFWithPageNums {
@Schema(description = "Custom margin: small/medium/large", allowableValues = {"small", "medium", "large"})

View file

@ -2,9 +2,11 @@ package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.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.", required = false, defaultValue = "false")

View file

@ -2,9 +2,11 @@ package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.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.", required = false, defaultValue = "false")

View file

@ -4,8 +4,10 @@ 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", required = true)
private MultipartFile fileInput;

View file

@ -1,12 +1,14 @@
package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import stirling.software.SPDF.model.api.PDFFile;
import java.util.Map;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class MetadataRequest extends PDFFile {
@Schema(description = "Delete all metadata if set to true")

View file

@ -2,9 +2,11 @@ package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.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.",

View file

@ -1,12 +1,14 @@
package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import stirling.software.SPDF.model.api.PDFFile;
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.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class OverlayImageRequest extends PDFFile {
@Schema(description = "The image file to be overlaid onto the PDF.")

View file

@ -1,13 +1,14 @@
package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import stirling.software.SPDF.model.api.PDFFile;
import java.util.List;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class ProcessPdfWithOcrRequest extends PDFFile {
@Schema(description = "List of languages to use in OCR processing")

View file

@ -2,9 +2,11 @@ package stirling.software.SPDF.model.api.misc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class RemoveBlankPagesRequest extends PDFFile {
@Schema(description = "The threshold value to determine blank pages", example = "10", defaultValue = "10")

View file

@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.security;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.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)", defaultValue = "")

View file

@ -1,11 +1,14 @@
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 org.springframework.web.multipart.MultipartFile;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class AddWatermarkRequest extends PDFFile {
@Schema(description = "The watermark type (text or image)", required = true)

View file

@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.security;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class PDFPasswordRequest extends PDFFile {
@Schema(description = "The password of the PDF file", required = true)

View file

@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.security;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class RedactPdfRequest extends PDFFile {
@Schema(description = "List of text to redact from the PDF", type = "string", required = true)

View file

@ -2,10 +2,11 @@ package stirling.software.SPDF.model.api.security;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class SanitizePdfRequest extends PDFFile {
@Schema(description = "Remove JavaScript actions from the PDF", defaultValue = "false")

View file

@ -1,11 +1,14 @@
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 org.springframework.web.multipart.MultipartFile;
import lombok.EqualsAndHashCode;
import stirling.software.SPDF.model.api.PDFFile;
@Data
@EqualsAndHashCode(callSuper=true)
public class SignPDFWithCertRequest extends PDFFile {
@Schema(description = "The type of the digital certificate", allowableValues = { "PKCS12", "PEM" })