openAtPageIndex property

int? get openAtPageIndex

Index of the page the document opens at, when the destination is explicit.

Implementation

int? get openAtPageIndex {
  final value = _resolveDict(_catalog[PdfNameTokens.openAction]);
  PdfDataType? destination = _catalog[PdfNameTokens.openAction];
  if (value != null) {
    // `/OpenAction` can also be a `/GoTo` action.
    destination = value[PdfNameTokens.d];
  }
  if (destination is! PdfArray || destination.values.isEmpty) return null;

  final target = destination.values.first;
  final id = _objectNumberOf(target);
  if (id == null) return null;

  final pages = document.pdfPageList.pages;
  for (var i = 0; i < pages.length; i++) {
    if (pages[i].objser == id) return i;
  }
  return null;
}