diff --git a/stirling-pdf/src/main/resources/static/js/DecryptFiles.js b/stirling-pdf/src/main/resources/static/js/DecryptFiles.js index 340773cb7..67349a012 100644 --- a/stirling-pdf/src/main/resources/static/js/DecryptFiles.js +++ b/stirling-pdf/src/main/resources/static/js/DecryptFiles.js @@ -125,7 +125,7 @@ export class DecryptFile { } else if (error.code === pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) { return {isEncrypted: true, requiresPassword: false}; } - } else if (error.name === 'InvalidPDFException' || + } else if (error.name === 'InvalidPDFException' || (error.message && error.message.includes('Invalid PDF structure'))) { // Handle corrupted PDF files console.error('Corrupted PDF detected:', error); diff --git a/stirling-pdf/src/main/resources/static/js/downloader.js b/stirling-pdf/src/main/resources/static/js/downloader.js index c5a1a91db..301b0411b 100644 --- a/stirling-pdf/src/main/resources/static/js/downloader.js +++ b/stirling-pdf/src/main/resources/static/js/downloader.js @@ -238,7 +238,7 @@ ); throw decryptError; } - } else if (error.name === 'InvalidPDFException' || + } else if (error.name === 'InvalidPDFException' || (error.message && error.message.includes('Invalid PDF structure'))) { // Handle corrupted PDF files console.log(`Corrupted PDF detected: ${file.name}`, error); diff --git a/stirling-pdf/src/main/resources/static/js/fileInput.js b/stirling-pdf/src/main/resources/static/js/fileInput.js index b728792f1..71b6a1ebf 100644 --- a/stirling-pdf/src/main/resources/static/js/fileInput.js +++ b/stirling-pdf/src/main/resources/static/js/fileInput.js @@ -226,7 +226,7 @@ function setupFileInput(chooser) { try { const { isEncrypted, requiresPassword } = await decryptFile.checkFileEncrypted(file); - if (file.type === 'application/pdf' && isEncrypted && + if (file.type === 'application/pdf' && isEncrypted && !window.location.pathname.includes('remove-password')) { decryptedFile = await decryptFile.decryptFile(file, requiresPassword); if (!decryptedFile) throw new Error('File decryption failed.'); @@ -236,13 +236,13 @@ function setupFileInput(chooser) { } catch (error) { console.error(`Error decrypting file: ${file.name}`, error); - + // Check if this is a PDF corruption error if (error.message && error.message.includes('PDF file is corrupted')) { // The error banner is already shown by DecryptFiles.js, just continue with the file console.warn(`Continuing with corrupted PDF file: ${file.name}`); } - + if (!file.uniqueId) file.uniqueId = UUID.uuidv4(); return file; }