namedDestination property

PdfNamedDestination? get namedDestination

Gets or sets the named destination in outline.

//Create a new document.
PdfDocument document = PdfDocument();
//Create a named destination.
PdfNamedDestination namedDestination = PdfNamedDestination('Page 1')
  ..destination = PdfDestination(document.pages.add(), Offset(100, 300));
//Add the named destination
document.namedDestinationCollection.add(namedDestination);
//Create document bookmarks.
document.bookmarks.add('Page 1')
  //Set the named destination.
  ..namedDestination = namedDestination
  ..color = PdfColor(255, 0, 0);
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();

Implementation

PdfNamedDestination? get namedDestination {
  if (_isLoadedBookmark) {
    _namedDestination ??= _obtainNamedDestination();
    return _namedDestination;
  } else {
    return _namedDestination;
  }
}
set namedDestination (PdfNamedDestination? value)

Implementation

set namedDestination(PdfNamedDestination? value) {
  if (value != null && _namedDestination != value) {
    _namedDestination = value;
    final PdfDictionary dictionary = PdfDictionary();
    dictionary.setProperty(
        PdfDictionaryProperties.d, PdfString(_namedDestination!.title));
    dictionary.setProperty(
        PdfDictionaryProperties.s, PdfName(PdfDictionaryProperties.goTo));
    dictionary.setProperty(
        PdfDictionaryProperties.a, PdfReferenceHolder(dictionary));
  }
}