page-index-out-of-range
- Type: error
- Kind:
usage(the caller misused the API)
What happened
A link (LinkTarget::Page), an outline item or a named destination (Builder::destination) names a page index the document doesn’t have when the build finishes.
Why
Page targets are resolved when Builder::finish (or Appender::finish) runs, so a link can name a page added after its own; by then every index must be one of the document’s pages. Indexes are 0-based (ADR 0027 §6).
How to fix
Use an index below the document’s page count, or add the page before finishing.
Example
surface.link(rect, LinkTarget::Page { index: 5, fit: Fit::Page }, None);builder.finish()?; // page-index-out-of-range: the document has 2 pagesData fields
index: the 0-based index given.count: the number of pages.