feat:Setup Prettier for code formatting

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

View File

@@ -3,25 +3,31 @@ import { downloadFile } from '../utils/helpers.js';
import { state } from '../state.js';
export async function flatten() {
if (!state.pdfDoc) {
showAlert('Error', 'PDF not loaded.');
return;
}
showLoader('Flattening PDF...');
try {
const form = state.pdfDoc.getForm();
form.flatten();
if (!state.pdfDoc) {
showAlert('Error', 'PDF not loaded.');
return;
}
showLoader('Flattening PDF...');
try {
const form = state.pdfDoc.getForm();
form.flatten();
const flattenedBytes = await state.pdfDoc.save();
downloadFile(new Blob([flattenedBytes], { type: 'application/pdf' }), 'flattened.pdf');
} catch (e) {
console.error(e);
if (e.message.includes('getForm')) {
showAlert('No Form Found', 'This PDF does not contain any form fields to flatten.');
} else {
showAlert('Error', 'Could not flatten the PDF.');
}
} finally {
hideLoader();
const flattenedBytes = await state.pdfDoc.save();
downloadFile(
new Blob([flattenedBytes], { type: 'application/pdf' }),
'flattened.pdf'
);
} catch (e) {
console.error(e);
if (e.message.includes('getForm')) {
showAlert(
'No Form Found',
'This PDF does not contain any form fields to flatten.'
);
} else {
showAlert('Error', 'Could not flatten the PDF.');
}
}
} finally {
hideLoader();
}
}