nUp static method

Future<Uint8List?> nUp(
  1. UPdfDocument document, {
  2. int columns = 2,
  3. int rows = 1,
  4. Size sheet = const Size(841.89, 595.28),
  5. double gap = 8,
})

Implementation

static Future<Uint8List?> nUp(UPdfDocument document, {int columns = 2, int rows = 1, Size sheet = const Size(841.89, 595.28), double gap = 8}) async {
  if (columns < 1 || rows < 1) return null;
  final UPdfComposer composer = UPdfComposer();
  final int perSheet = columns * rows;
  for (int start = 0; start < document.pageCount; start += perSheet) {
    final List<int> indices = <int>[];
    for (int i = start; i < start + perSheet && i < document.pageCount; i++) {
      indices.add(i);
    }
    await _composeSheet(composer, document, indices, columns, rows, sheet, gap);
  }
  if (composer.pageCount == 0) return null;
  return composer.build();
}