mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-11-16 01:21:16 +01:00
fix(repair): suppress corrupted PDF error/warning banner on repair page (#4434)
# Description of Changes Updated JS/HTML to ignore PDF corruption warning on repair-pdf html, since if user is already there, it may be safely assumed that the user is well-aware about said PDF corruption, and does not actually benefit from the information Closes: #4432 <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [x] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --------- Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
60c7ba40a6
commit
fda1d6bc73
@ -128,11 +128,15 @@ export class DecryptFile {
|
|||||||
(error.message && error.message.includes('Invalid PDF structure'))) {
|
(error.message && error.message.includes('Invalid PDF structure'))) {
|
||||||
// Handle corrupted PDF files
|
// Handle corrupted PDF files
|
||||||
console.error('Corrupted PDF detected:', error);
|
console.error('Corrupted PDF detected:', error);
|
||||||
this.showErrorBanner(
|
if (window.stirlingPDF.currentPage !== 'repair') {
|
||||||
`${window.stirlingPDF.pdfCorruptedMessage.replace('{0}', file.name)}`,
|
this.showErrorBanner(
|
||||||
error.stack || '',
|
`${window.stirlingPDF.pdfCorruptedMessage.replace('{0}', file.name)}`,
|
||||||
`${window.stirlingPDF.tryRepairMessage}`
|
error.stack || '',
|
||||||
);
|
`${window.stirlingPDF.tryRepairMessage}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log('Suppressing corrupted PDF warning banner on repair page');
|
||||||
|
}
|
||||||
throw new Error('PDF file is corrupted.');
|
throw new Error('PDF file is corrupted.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -249,10 +249,15 @@
|
|||||||
(error.message && error.message.includes('Invalid PDF structure'))) {
|
(error.message && error.message.includes('Invalid PDF structure'))) {
|
||||||
// Handle corrupted PDF files
|
// Handle corrupted PDF files
|
||||||
console.log(`Corrupted PDF detected: ${file.name}`, error);
|
console.log(`Corrupted PDF detected: ${file.name}`, error);
|
||||||
showErrorBanner(
|
if (window.stirlingPDF.currentPage !== 'repair') {
|
||||||
`${window.stirlingPDF.pdfCorruptedMessage.replace('{0}', file.name)}`,
|
showErrorBanner(
|
||||||
`${window.stirlingPDF.tryRepairMessage}`
|
`${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;
|
throw error;
|
||||||
} else {
|
} else {
|
||||||
console.log(`Error loading PDF: ${file.name}`, error);
|
console.log(`Error loading PDF: ${file.name}`, error);
|
||||||
|
|||||||
@ -380,6 +380,7 @@
|
|||||||
window.stirlingPDF.uploadLimitExceededPlural = /*[[#{uploadLimitExceededPlural}]]*/ 'are too large. Maximum allowed size is';
|
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.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.tryRepairMessage = /*[[#{error.tryRepair}]]*/ 'Try using the Repair PDF feature to fix corrupted files.';
|
||||||
|
window.stirlingPDF.currentPage = /*[[${currentPage}]]*/ '';
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<script type="module" th:src="@{'/pdfjs-legacy/pdf.mjs'}"></script>
|
<script type="module" th:src="@{'/pdfjs-legacy/pdf.mjs'}"></script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user