PageLabel Class |
PDF page labels can be used to describe a page. This is used to allow for non-sequential page numbering or the addition of arbitrary labels for a page (such as the inclusion of Roman numerals at the beginning of a book). PDFNet PageLabel object can be used to specify the numbering style to use (for example, upper- or lower-case Roman, decimal, and so forth), the starting number for the first page, and an arbitrary prefix to be pre-appended to each number (for example, "A-" to generate "A-1", "A-2", "A-3", and so forth.)
PageLabel corresponds to the PDF Page Label object (Section 8.3.1, 'Page Labels' in the PDF Reference Manual.
Each page in a PDF document is identified by an integer page index that expresses the page's relative position within the document. In addition, a document may optionally define page labels to identify each page visually on the screen or in print. Page labels and page indices need not coincide: the indices are fixed, running consecutively through the document starting from 1 for the first page, but the labels can be specified in any way that is appropriate for the particular document. For example, if the document begins with 12 pages of front matter numbered in roman numerals and the remainder of the document is numbered in Arabic, the first page would have a page index of 1 and a page label of i, the twelfth page would have index 12 and label xii, and the thirteenth page would have index 13 and label 1.
For purposes of page labeling, a document can be divided into labeling ranges, each of which is a series of consecutive pages using the same numbering system. Pages within a range are numbered sequentially in ascending order. A page's label consists of a numeric portion based on its position within its labeling range, optionally preceded by a label prefix denoting the range itself. For example, the pages in an appendix might be labeled with decimal numeric portions prefixed with the string "A-" and the resulting page labels would be "A-1", "A-2",
There is no default numbering style; if no 'S' (Style) entry is present, page labels consist solely of a label prefix with no numeric portion. For example, if the 'P' entry (Prefix) specifies the label prefix "Appendix", each page is simply labeled "Appendix" with no page number. If the 'P' entry is also missing or empty, the page label is an empty string.doc.SetPageLabel(1, PageLabel::Create(doc, PageLabel::e_roman_uppercase, "My Prefix ", 1));
PageLabel L2 = PageLabel::Create(doc, PageLabel::e_decimal, "My Prefix ", 4); doc.SetPageLabel(4, L2);
PageLabel L3 = PageLabel::Create(doc, PageLabel::e_alphabetic_uppercase, "My Prefix ", 1); doc.SetPageLabel(7, L3);
PageLabel label = new PageLabel(); for (int i=1; i<=doc.GetPageCount(); ++i) { label = doc.GetPageLabel(i); if (label.IsValid()) { string title = label.GetLabelTitle(i); }
Namespace: pdftron.PDF
public sealed class PageLabel : IClosable
The PageLabel type exposes the following members.
Name | Description | |
---|---|---|
Close | ||
Create | Creates a new PageLabel.
| |
Equals | (Inherited from Object.) | |
GetFirstPageNum | Gets the first page num.
| |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetLabelTitle | Gets full tittle of the page label
| |
GetLastPageNum | Gets the last page num.
| |
GetPrefix | Gets the prefix.
| |
GetSDFObj | Gets the sDF obj.
| |
GetStart | Gets the start.
| |
GetStyle | Gets the style.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
IsValid | Checks if is valid.
| |
SetPrefix | Sets the prefix.
| |
SetStart | Sets the start.
| |
SetStyle | Sets the numbering style for the label.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |