feat:Setup Prettier for code formatting

This commit is contained in:
NanditaPatil-dotcom committed 2025-10-17 11:37:32 +05:30
1 parent 87c191213c
commit f1d830d81d
96 files changed
+9420 -7154

No files matched your search

+26 -17
View File
@@ -5,22 +5,31 @@ import { state } from '../state.js';
import { PDFDocument as PDFLibDocument } from 'pdf-lib';
export async function reversePages() {
if (!state.pdfDoc) { showAlert('Error', 'PDF not loaded.'); return; }
showLoader('Reversing page order...');
try {
const newPdf = await PDFLibDocument.create();
const pageCount = state.pdfDoc.getPageCount();
const reversedIndices = Array.from({ length: pageCount }, (_, i) => pageCount - 1 - i);
if (!state.pdfDoc) {
showAlert('Error', 'PDF not loaded.');
return;
}
showLoader('Reversing page order...');
try {
const newPdf = await PDFLibDocument.create();
const pageCount = state.pdfDoc.getPageCount();
const reversedIndices = Array.from(
{ length: pageCount },
(_, i) => pageCount - 1 - i
);
const copiedPages = await newPdf.copyPages(state.pdfDoc, reversedIndices);
copiedPages.forEach((page: any) => newPdf.addPage(page));
const copiedPages = await newPdf.copyPages(state.pdfDoc, reversedIndices);
copiedPages.forEach((page: any) => newPdf.addPage(page));
const newPdfBytes = await newPdf.save();
downloadFile(new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }), 'reversed.pdf');
} catch (e) {
console.error(e);
showAlert('Error', 'Could not reverse the PDF pages.');
} finally {
hideLoader();
}
}
const newPdfBytes = await newPdf.save();
downloadFile(
new Blob([new Uint8Array(newPdfBytes)], { type: 'application/pdf' }),
'reversed.pdf'
);
} catch (e) {
console.error(e);
showAlert('Error', 'Could not reverse the PDF pages.');
} finally {
hideLoader();
}
}