Table of Contents

Class PdfPageLabels

Namespace
MiPdf
Assembly
MiPdf.dll

The page labels of a document (/PageLabels in the catalog, ISO 32000-1, 12.4.2): logical page numbers such as "i, ii, iii" for a preface followed by "1, 2, 3". Viewers show them instead of the physical page number.

public sealed class PdfPageLabels : IReadOnlyList<PdfPageLabelRange>, IReadOnlyCollection<PdfPageLabelRange>, IEnumerable<PdfPageLabelRange>, IEnumerable
Inheritance
PdfPageLabels
Implements
Inherited Members

Remarks

Labels belong to page positions: page operations (RemovePage(int), InsertPage(int, PdfRectangle?), imports and merges) keep the ranges as they are and do not shift them.

Properties

Count

Number of ranges. The ranges are read from the number tree (flat /Nums arrays and /Kids) and ordered by their first page.

public int Count { get; }

Property Value

int

this[int]

The range at index (ordered by first page).

public PdfPageLabelRange this[int index] { get; }

Parameters

index int

Property Value

PdfPageLabelRange

Methods

Add(PdfPageLabelRange)

Adds range; an existing range at the same page is replaced.

public void Add(PdfPageLabelRange range)

Parameters

range PdfPageLabelRange

Add(int, PdfPageLabelStyle, string?, int)

Adds a range that starts at startPage (1-based) and lasts until the next range; an existing range at the same page is replaced.

public void Add(int startPage, PdfPageLabelStyle style, string? prefix = null, int startNumber = 1)

Parameters

startPage int
style PdfPageLabelStyle
prefix string
startNumber int

Clear()

Removes all page labels.

public void Clear()

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<PdfPageLabelRange> GetEnumerator()

Returns

IEnumerator<PdfPageLabelRange>

An enumerator that can be used to iterate through the collection.

GetLabel(int)

The label of page pageNumber (1-based). Pages before the first range, and all pages of a document without page labels, get their decimal page number.

public string GetLabel(int pageNumber)

Parameters

pageNumber int

Returns

string

Remove(int)

Removes the range that starts at startPage. Returns false if there is none.

public bool Remove(int startPage)

Parameters

startPage int

Returns

bool