Page labels

edit

Viewers show the labels of the pages instead of their numbers. PageLabels holds ranges of pages, each with a numbering style, a prefix and the number of its first page:

// i, ii, iii for the front matter, then 1, 2, 3... and A-1, A-2 for the appendix
document.PageLabels.Set(0, new PdfPageLabel(PdfPageLabelStyle.LowercaseRoman));
document.PageLabels.Set(3, new PdfPageLabel(PdfPageLabelStyle.Decimal));
document.PageLabels.Set(6, new PdfPageLabel(PdfPageLabelStyle.Decimal, prefix: "A-"));
  • A range starts at the page given to Set and ends before the next range. Remove and Clear remove ranges.
  • PdfPageLabelStyle is decimal, uppercase or lowercase Roman numerals, uppercase or lowercase letters (A to Z, then AA to ZZ...), or none: the label is then the prefix alone.
  • PdfPage.Label and GetLabel give the label of a page; it is null when the document has no labels.
  • The labels are written to the document at once, as one node of a number tree; the labels of a file are read from its whole tree.