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

This commit is contained in:
alam00000 committed 2026-03-26 14:42:48 +05:30
1 parent 9278774b8a
commit bd44108296
19 files changed
+89 -78

No files matched your search

+2 -5
View File
@@ -306,9 +306,7 @@ async function performCrop() {
async function performMetadataCrop(
cropData: Record<number, any>
): Promise<Uint8Array> {
const pdfToModify = await loadPdfDocument(cropperState.originalPdfBytes!, {
throwOnInvalidObject: false,
});
const pdfToModify = await loadPdfDocument(cropperState.originalPdfBytes!);
for (const pageNum in cropData) {
const pdfJsPage = await cropperState.pdfDoc.getPage(Number(pageNum));
@@ -350,8 +348,7 @@ async function performFlatteningCrop(
): Promise<Uint8Array> {
const newPdfDoc = await PDFLibDocument.create();
const sourcePdfDocForCopying = await loadPdfDocument(
cropperState.originalPdfBytes!,
{ throwOnInvalidObject: false }
cropperState.originalPdfBytes!
);
const totalPages = cropperState.pdfDoc.numPages;