feat: add PDF password prompt and centralized pdf-lib loader with auto-repair

This commit is contained in:
alam00000
2026-03-26 14:42:48 +05:30
parent 9278774b8a
commit bd44108296
19 changed files with 89 additions and 78 deletions
+10 -12
View File
@@ -90,19 +90,17 @@ document.addEventListener('DOMContentLoaded', () => {
// Load PDF Document
try {
if (!state.pdfDoc) {
const result = await loadPdfWithPasswordPrompt(file);
if (!result) {
state.files = [];
updateUI();
return;
}
result.pdf.destroy();
state.files[0] = result.file;
state.pdfDoc = await loadPdfDocument(result.bytes);
const result = await loadPdfWithPasswordPrompt(file);
if (!result) {
state.files = [];
updateUI();
return;
}
// Update page count
metaSpan.textContent = `${formatBytes(file.size)} • ${state.pdfDoc.getPageCount()} pages`;
const pageCount = result.pdf.numPages;
result.pdf.destroy();
state.files[0] = result.file;
state.pdfDoc = await loadPdfDocument(result.bytes);
metaSpan.textContent = `${formatBytes(file.size)} • ${pageCount} pages`;
} catch (error) {
console.error('Error loading PDF:', error);
showAlert('Error', 'Failed to load PDF file.');