applyToDocument method

int applyToDocument(
  1. PdfDocument document, {
  2. int from = 0,
  3. int? to,
})

Numbers the pages of document in the range [from, to), zero based.

A null to means up to the last page. Returns the number of pages stamped.

The page list is the one from PdfPageContentEditor.distinctPages: a loaded document registers each page twice in pdfPageList.pages, and numbering over the raw list would stamp the same page twice.

Implementation

int applyToDocument(
  PdfDocument document, {
  int from = 0,
  int? to,
}) {
  final pages = PdfPageContentEditor.distinctPages(document);
  final first = from < 0 ? 0 : from;
  final last = to == null || to > pages.length ? pages.length : to;
  if (first >= last) return 0;
  return applyToPages(pages.sublist(first, last));
}