diff --git a/app/core/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java b/app/core/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java index f221e3a63..97cbf9906 100644 --- a/app/core/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java +++ b/app/core/src/main/java/stirling/software/SPDF/controller/api/misc/OCRController.java @@ -92,6 +92,7 @@ public class OCRController { String ocrType = request.getOcrType(); String ocrRenderType = request.getOcrRenderType(); Boolean removeImagesAfter = request.isRemoveImagesAfter(); + boolean invalidateDigitalSignatures = request.isInvalidateDigitalSignatures(); if (selectedLanguages == null || selectedLanguages.isEmpty()) { throw ExceptionUtils.createOcrLanguageRequiredException(); @@ -130,6 +131,7 @@ public class OCRController { ocrType, ocrRenderType, removeImagesAfter, + invalidateDigitalSignatures, tempInputFile.getPath(), tempOutputFile.getPath(), sidecarTextFile != null ? sidecarTextFile.getPath() : null); @@ -203,6 +205,7 @@ public class OCRController { String ocrType, String ocrRenderType, Boolean removeImagesAfter, + boolean invalidateDigitalSignatures, Path tempInputFile, Path tempOutputFile, Path sidecarTextPath) @@ -243,6 +246,9 @@ public class OCRController { command.add("--force-ocr"); } } + if (invalidateDigitalSignatures) { + command.add("--invalidate-digital-signatures"); + } command.addAll( Arrays.asList( diff --git a/app/core/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java b/app/core/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java index 2955d7160..04ecda3d8 100644 --- a/app/core/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java +++ b/app/core/src/main/java/stirling/software/SPDF/model/api/misc/ProcessPdfWithOcrRequest.java @@ -46,4 +46,9 @@ public class ProcessPdfWithOcrRequest extends PDFFile { @Schema(description = "Remove images from the output PDF if set to true") private boolean removeImagesAfter; + + @Schema( + description = + "Invalidate digital signatures in the PDF to allow OCR processing. WARNING: This will make any digital signatures in the document invalid.") + private boolean invalidateDigitalSignatures; } diff --git a/frontend/public/locales/en-GB/translation.toml b/frontend/public/locales/en-GB/translation.toml index 5d9f08467..eae32fafb 100644 --- a/frontend/public/locales/en-GB/translation.toml +++ b/frontend/public/locales/en-GB/translation.toml @@ -2028,6 +2028,10 @@ help = "Please read this documentation on how to use this for other languages an credit = "This service uses qpdf and Tesseract for OCR." submit = "Process PDF with OCR" +[ocr.invalidateSignatures] +label = "Invalidate digital signatures" +warning = "Warning: Enabling this option will invalidate any digital signatures in the PDF. The document will no longer be legally valid as a signed document." + [ocr.selectText] 1 = "Select languages that are to be detected within the PDF (Ones listed are the ones currently detected):" 2 = "Produce text file containing OCR text alongside the OCR'ed PDF" diff --git a/frontend/src/core/components/tools/ocr/AdvancedOCRSettings.tsx b/frontend/src/core/components/tools/ocr/AdvancedOCRSettings.tsx index ca4d5fc24..e4663d9c3 100644 --- a/frontend/src/core/components/tools/ocr/AdvancedOCRSettings.tsx +++ b/frontend/src/core/components/tools/ocr/AdvancedOCRSettings.tsx @@ -35,6 +35,7 @@ const AdvancedOCRSettings: React.FC = ({ { value: 'deskew', label: t('ocr.settings.advancedOptions.deskew', 'Deskew pages'), isSpecial: false }, { value: 'clean', label: t('ocr.settings.advancedOptions.clean', 'Clean input file'), isSpecial: false }, { value: 'cleanFinal', label: t('ocr.settings.advancedOptions.cleanFinal', 'Clean final output'), isSpecial: false }, + { value: 'invalidateDigitalSignatures', label: t('ocr.invalidateSignatures.label', 'Invalidate digital signatures'), isSpecial: false }, ]; // Handle individual checkbox changes diff --git a/frontend/src/core/components/tooltips/useAdvancedOCRTips.ts b/frontend/src/core/components/tooltips/useAdvancedOCRTips.ts index 004a97066..2bba137ab 100644 --- a/frontend/src/core/components/tooltips/useAdvancedOCRTips.ts +++ b/frontend/src/core/components/tooltips/useAdvancedOCRTips.ts @@ -28,6 +28,10 @@ export const useAdvancedOCRTips = (): TooltipContent => { { title: t("ocr.tooltip.advanced.cleanFinal.title", "Clean Final Output"), description: t("ocr.tooltip.advanced.cleanFinal.text", "Post-processes the final PDF by removing OCR artefacts and optimising the text layer for better readability and smaller file size.") + }, + { + title: t("ocr.invalidateSignatures.label", "Invalidate digital signatures"), + description: t("ocr.invalidateSignatures.warning", "Warning: Enabling this option will invalidate any digital signatures in the PDF. The document will no longer be legally valid as a signed document.") } ] }; diff --git a/frontend/src/core/hooks/tools/ocr/useOCROperation.ts b/frontend/src/core/hooks/tools/ocr/useOCROperation.ts index 6e86a083e..fe980de6e 100644 --- a/frontend/src/core/hooks/tools/ocr/useOCROperation.ts +++ b/frontend/src/core/hooks/tools/ocr/useOCROperation.ts @@ -49,6 +49,7 @@ export const buildOCRFormData = (parameters: OCRParameters, file: File): FormDat formData.append('clean', parameters.additionalOptions.includes('clean').toString()); formData.append('cleanFinal', parameters.additionalOptions.includes('cleanFinal').toString()); formData.append('removeImagesAfter', parameters.additionalOptions.includes('removeImagesAfter').toString()); + formData.append('invalidateDigitalSignatures', parameters.additionalOptions.includes('invalidateDigitalSignatures').toString()); return formData; };