namedDestinationCollection property

PdfNamedDestinationCollection get namedDestinationCollection

Gets the named destination collection of the document.

Implementation

PdfNamedDestinationCollection get namedDestinationCollection {
  if (_helper.isLoadedDocument) {
    if (_namedDestinations == null) {
      if (_helper.catalog.containsKey(PdfDictionaryProperties.names) &&
          (_namedDestinations == null)) {
        final PdfDictionary? namedDestinations = PdfCrossTable.dereference(
            _helper.catalog[PdfDictionaryProperties.names]) as PdfDictionary?;
        _namedDestinations = PdfNamedDestinationCollectionHelper.load(
            namedDestinations, _helper.crossTable);
      }
      _namedDestinations ??= _createNamedDestinations();
    }
    return _namedDestinations!;
  } else {
    if (_namedDestinations == null) {
      _namedDestinations = PdfNamedDestinationCollection();
      _helper.catalog[PdfDictionaryProperties.names] =
          PdfReferenceHolder(_namedDestinations);
      final PdfReferenceHolder? names = _helper
          .catalog[PdfDictionaryProperties.names] as PdfReferenceHolder?;
      if (names != null) {
        final PdfDictionary? dic = names.object as PdfDictionary?;
        if (dic != null) {
          dic[PdfDictionaryProperties.dests] =
              PdfReferenceHolder(_namedDestinations);
        }
      }
    }
    return _namedDestinations!;
  }
}