addBlankPageAt method
Adds a blank page at the given pageIndex in the PDF.
Returns the updated file if successful, or null otherwise.
Implementation
Future<File?> addBlankPageAt(int pageIndex, File pdfFile) async {
final pdfDoc = PdfDocument(inputBytes: await pdfFile.readAsBytes());
if (pageIndex < 0 || pageIndex > pdfDoc.pages.count) {
debugPrint('Invalid page index: $pageIndex');
return null;
}
final Size pageSize = Size(
pdfDoc.pages[0].getClientSize().width,
pdfDoc.pages[0].getClientSize().height,
);
pdfDoc.pages.insert(pageIndex, pageSize);
return await saveFile(pdfDoc: pdfDoc, addTimestap: false, pdfFile: pdfFile);
}