This commit is contained in:
Anthony Stirling
2023-09-13 00:46:30 +01:00
parent 2c0fb33548
commit 82b641458f
23 changed files with 121 additions and 100 deletions

View File

@@ -35,7 +35,7 @@ public class AutoRenameController {
@Operation(summary = "Extract header from PDF file", description = "This endpoint accepts a PDF file and attempts to extract its title or header based on heuristics. Input:PDF Output:PDF Type:SISO")
public ResponseEntity<byte[]> extractHeader(@ModelAttribute ExtractHeaderRequest request) throws Exception {
MultipartFile file = request.getFileInput();
Boolean useFirstTextAsFallback = request.getUseFirstTextAsFallback();
Boolean useFirstTextAsFallback = request.isUseFirstTextAsFallback();
PDDocument document = PDDocument.load(file.getInputStream());
PDFTextStripper reader = new PDFTextStripper() {

View File

@@ -48,7 +48,7 @@ public class CompressController {
public ResponseEntity<byte[]> optimizePdf(@ModelAttribute OptimizePdfRequest request) throws Exception {
MultipartFile inputFile = request.getFileInput();
Integer optimizeLevel = request.getOptimizeLevel();
String expectedOutputSizeString = request.getExpectedOutputSizeString();
String expectedOutputSizeString = request.getExpectedOutputSize();
if(expectedOutputSizeString == null && optimizeLevel == null) {

View File

@@ -48,7 +48,7 @@ public class MetadataController {
MultipartFile pdfFile = request.getFileInput();
// Extract metadata information
Boolean deleteAll = request.getDeleteAll();
Boolean deleteAll = request.isDeleteAll();
String author = request.getAuthor();
String creationDate = request.getCreationDate();
String creator = request.getCreator();
@@ -61,7 +61,9 @@ public class MetadataController {
// Extract additional custom parameters
Map<String, String> allRequestParams = request.getAllRequestParams();
if(allRequestParams == null) {
allRequestParams = new java.util.HashMap<String, String>();
}
// Load the PDF file into a PDDocument
PDDocument document = PDDocument.load(pdfFile.getBytes());

View File

@@ -53,14 +53,14 @@ public class OCRController {
description = "This endpoint processes a PDF file using OCR (Optical Character Recognition). Users can specify languages, sidecar, deskew, clean, cleanFinal, ocrType, ocrRenderType, and removeImagesAfter options. Input:PDF Output:PDF Type:SI-Conditional")
public ResponseEntity<byte[]> processPdfWithOCR(@ModelAttribute ProcessPdfWithOcrRequest request) throws IOException, InterruptedException {
MultipartFile inputFile = request.getFileInput();
List<String> selectedLanguages = request.getSelectedLanguages();
Boolean sidecar = request.getSidecar();
Boolean deskew = request.getDeskew();
Boolean clean = request.getClean();
Boolean cleanFinal = request.getCleanFinal();
List<String> selectedLanguages = request.getLanguages();
Boolean sidecar = request.isSidecar();
Boolean deskew = request.isDeskew();
Boolean clean = request.isClean();
Boolean cleanFinal = request.isCleanFinal();
String ocrType = request.getOcrType();
String ocrRenderType = request.getOcrRenderType();
Boolean removeImagesAfter = request.getRemoveImagesAfter();
Boolean removeImagesAfter = request.isRemoveImagesAfter();
// --output-type pdfa
if (selectedLanguages == null || selectedLanguages.isEmpty()) {
throw new IOException("Please select at least one language.");