new PageLabel( [mp_obj] [, m_first_page] [, m_last_page])
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",
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
mp_obj |
PDFNet.Obj |
<optional> |
|
m_first_page |
number |
<optional> |
|
m_last_page |
number |
<optional> |
Properties:
Name | Type | Description |
---|---|---|
mp_obj |
PDFNet.Obj | |
m_first_page |
number | |
m_last_page |
number |
Members
-
<static> Style
-
Properties:
Name Type Description e_decimal
number e_roman_uppercase
number e_roman_lowercase
number e_alphabetic_uppercase
number e_alphabetic_lowercase
number e_none
number
Methods
-
<static> create(doc, style [, prefix] [, start_at])
-
Creates a new PageLabel.
Parameters:
Name Type Argument Description doc
PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc A document to which the page label is added. style
number PDFNet.PageLabel.Style = { e_decimal : 0 e_roman_uppercase : 1 e_roman_lowercase : 2 e_alphabetic_uppercase : 3 e_alphabetic_lowercase : 4 e_none : 5 }
The numbering style for the label.prefix
string <optional>
The string used to prefix the numeric portion of the page label. start_at
number <optional>
the value to use when generating the numeric portion of the first label in this range; must be greater than or equal to 1. Returns:
A promise that resolves to newly created PageLabel object.- Type
- Promise.<PDFNet.PageLabel>
-
<static> createFromObj( [l] [, first_page] [, last_page])
-
Parameters:
Name Type Argument Description l
PDFNet.Obj <optional>
first_page
number <optional>
last_page
number <optional>
Returns:
A promise that resolves to an object of type: "PDFNet.PageLabel"- Type
- Promise.<PDFNet.PageLabel>
-
compare(d)
-
Parameters:
Name Type Description d
PDFNet.PageLabel Returns:
A promise that resolves to an object of type: "boolean"- Type
- Promise.<boolean>
-
getFirstPageNum()
-
Returns:
A promise that resolves to the first page in the range associated with this label or -1 if the label is not associated with any page.- Type
- Promise.<number>
-
getLabelTitle(page_num)
-
Parameters:
Name Type Description page_num
number Returns:
A promise that resolves to an object of type: "string"- Type
- Promise.<string>
-
getLastPageNum()
-
Returns:
A promise that resolves to the last page in the range associated with this label or -1 if the label is not associated with any page.- Type
- Promise.<number>
-
getPrefix()
-
Returns:
A promise that resolves to the string used to prefix the numeric portion of the page label- Type
- Promise.<string>
-
getSDFObj()
-
Returns:
A promise that resolves to the pointer to the underlying SDF/Cos object.- Type
- Promise.<PDFNet.Obj>
-
getStart()
-
Returns:
A promise that resolves to the value to use when generating the numeric portion of the first label in this range; must be greater than or equal to 1.- Type
- Promise.<number>
-
getStyle()
-
Returns:
A promise that resolves to page numbering style.- Type
- Promise.<number>
Example
Return value enum: <pre> PDFNet.PageLabel.Style = { e_decimal : 0 e_roman_uppercase : 1 e_roman_lowercase : 2 e_alphabetic_uppercase : 3 e_alphabetic_lowercase : 4 e_none : 5 } </pre>
-
isValid()
-
Returns:
A promise that resolves to whether this is a valid (non-null) PageLabel. If the function returns false the underlying SDF/Cos object is null or is not valid and the PageLabel object should be treated as null as well.- Type
- Promise.<boolean>
-
setPrefix(prefix)
-
Parameters:
Name Type Description prefix
string the string used to prefix the numeric portion of the page label. Returns:
- Type
- Promise.<void>
-
setStart(start_at)
-
Parameters:
Name Type Description start_at
number the value to use when generating the numeric portion of the first label in this range; must be greater than or equal to 1. Returns:
- Type
- Promise.<void>
-
setStyle(style)
-
Sets the numbering style for the label.
Parameters:
Name Type Description style
number PDFNet.PageLabel.Style = { e_decimal : 0 e_roman_uppercase : 1 e_roman_lowercase : 2 e_alphabetic_uppercase : 3 e_alphabetic_lowercase : 4 e_none : 5 }
the numbering style for the label. You may use label style to customize the page numbering schemes used throughout a document. There are three numbering formats: decimal (often used for normal page ranges) roman (often used for front matter such as a preface) alphabetic (often used for back matter such as appendices)Returns:
- Type
- Promise.<void>