tableOfContents property

Future<List<PdfTocEntry>> get tableOfContents

Returns the complete Table of Contents (bookmark/outline tree) for the document.

Each PdfTocEntry in the returned list is a root-level bookmark entry. PdfTocEntry.children provides nested sub-entries at arbitrary depth.

Returns an empty list when the document has no bookmarks — this is not an error condition.

Throws StateError if close has already been called.

Platform support: Native (dart:ffi) only. Stubs on unsupported platforms throw UnsupportedError immediately.

Example — print all top-level bookmark titles and their page numbers:

final toc = await doc.tableOfContents;
for (final entry in toc) {
  final page = entry.pageIndex != null ? 'page ${entry.pageIndex! + 1}' : '(no target)';
  print('${entry.title} → $page');
}

Implementation

Future<List<PdfTocEntry>> get tableOfContents => _impl.tableOfContents;