split static method

Future<List<Uint8List>> split(
  1. UPdfDocument document, {
  2. int pagesPerFile = 1,
})

Implementation

static Future<List<Uint8List>> split(UPdfDocument document, {int pagesPerFile = 1}) async {
  final List<Uint8List> out = <Uint8List>[];
  final int step = pagesPerFile < 1 ? 1 : pagesPerFile;
  for (int start = 0; start < document.pageCount; start += step) {
    final List<int> indices = <int>[];
    for (int i = start; i < start + step && i < document.pageCount; i++) {
      indices.add(i);
    }
    final Uint8List? bytes = await extractPages(document, indices);
    if (bytes != null) out.add(bytes);
  }
  return out;
}