diff --git a/app/core/src/main/resources/static/js/DecryptFiles.js b/app/core/src/main/resources/static/js/DecryptFiles.js index 0e5b58a92..e569d8839 100644 --- a/app/core/src/main/resources/static/js/DecryptFiles.js +++ b/app/core/src/main/resources/static/js/DecryptFiles.js @@ -128,11 +128,15 @@ export class DecryptFile { (error.message && error.message.includes('Invalid PDF structure'))) { // Handle corrupted PDF files console.error('Corrupted PDF detected:', error); - this.showErrorBanner( - `${window.stirlingPDF.pdfCorruptedMessage.replace('{0}', file.name)}`, - error.stack || '', - `${window.stirlingPDF.tryRepairMessage}` - ); + if (window.stirlingPDF.currentPage !== 'repair') { + this.showErrorBanner( + `${window.stirlingPDF.pdfCorruptedMessage.replace('{0}', file.name)}`, + error.stack || '', + `${window.stirlingPDF.tryRepairMessage}` + ); + } else { + console.log('Suppressing corrupted PDF warning banner on repair page'); + } throw new Error('PDF file is corrupted.'); } diff --git a/app/core/src/main/resources/static/js/downloader.js b/app/core/src/main/resources/static/js/downloader.js index 47e1b06af..9e074be5e 100644 --- a/app/core/src/main/resources/static/js/downloader.js +++ b/app/core/src/main/resources/static/js/downloader.js @@ -249,10 +249,15 @@ (error.message && error.message.includes('Invalid PDF structure'))) { // Handle corrupted PDF files console.log(`Corrupted PDF detected: ${file.name}`, error); - showErrorBanner( - `${window.stirlingPDF.pdfCorruptedMessage.replace('{0}', file.name)}`, - `${window.stirlingPDF.tryRepairMessage}` - ); + if (window.stirlingPDF.currentPage !== 'repair') { + showErrorBanner( + `${window.stirlingPDF.pdfCorruptedMessage.replace('{0}', file.name)}`, + `${window.stirlingPDF.tryRepairMessage}` + ); + } else { + // On repair page, suppress banner; user already knows and is repairing + console.log('Suppressing corrupted PDF banner on repair page'); + } throw error; } else { console.log(`Error loading PDF: ${file.name}`, error); diff --git a/app/core/src/main/resources/templates/fragments/common.html b/app/core/src/main/resources/templates/fragments/common.html index d3b888a1d..49c958914 100644 --- a/app/core/src/main/resources/templates/fragments/common.html +++ b/app/core/src/main/resources/templates/fragments/common.html @@ -380,6 +380,7 @@ window.stirlingPDF.uploadLimitExceededPlural = /*[[#{uploadLimitExceededPlural}]]*/ 'are too large. Maximum allowed size is'; window.stirlingPDF.pdfCorruptedMessage = /*[[#{error.pdfInvalid}]]*/ 'The PDF file "{0}" appears to be corrupted or has an invalid structure. Please try using the \'Repair PDF\' feature to fix the file before proceeding.'; window.stirlingPDF.tryRepairMessage = /*[[#{error.tryRepair}]]*/ 'Try using the Repair PDF feature to fix corrupted files.'; + window.stirlingPDF.currentPage = /*[[${currentPage}]]*/ ''; })();