mirror of
https://github.com/alam00000/bentopdf.git
synced 2026-11-07 00:28:39 +01:00
feat: add PDF password prompt and centralized pdf-lib loader with auto-repair
This commit is contained in:
@@ -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.');
|
||||
|
||||
Reference in New Issue
Block a user