Index
- Installation
- Getting Started
- Memory Usage
- Readers and Writers
- The Document Class
- Metadata
- Pages
- Canvas
- Page Layout and Mode
- Viewer Preferences
- Document Outline
- Page Labels
- Actions
- Destinations
- Annotations
- Embedded File Streams
- Colors and Color Spaces
- Page Formats and Boundaries
- Standard and Public Key Encryption
- Fonts and Encodings
- Corrupted Documents
- Reader Enabled Documents
- Refactor Old SetaPDF Code
- API Reference
Page Labels Reading and specifying page labels
Table of Contents
Introduction
A page in a PDF document could be identified by its page index that expresses the page's relative position within the document. Furthermore it is possible to optionally define page labels to identify a page visually on screen or in print.
Let's say you have a document index spreading over 3 pages while the first content pages should start with 1. With page labels the numbering could be restarted at the first content page. It is also possible to define a prefix and the numbering style (decimal, roman,...) for page labels.
A documents page labels are structured in labelling ranges. Each range is a series of consecutive pages using the same numbering system.
Handling Page Labels of Existing Documents
The handling of page labels is possible through the SetaPDF_Core_Document_Catalog_PageLabels
class. To get access to an instance the SetaPDF-Core component offers a helper method on the catalog instance of a document:
$pageLabels = $document->getCatalog()->getPageLabels();
To translate a page index to a page label defined in the document the class offers a simple helper method:
Description
Get the page label by a page number/index.
Parameters
- $pageNo : integer
The page number/index to get the page label for
- $encoding : string
The output encoding
Return Values
Returns the page label for the specific page number/index
Exceptions
Throws SetaPDF_Core_SecHandler_Exception
Throws SetaPDF_Core_Type_Exception
Following example will simply extract the page labels of an existing document:
Define Page Labels
Beside interpreting page labels of existing PDF documents the SetaPDF-Core component allows you to specify individual page range in new or existing PDF documents.
To add a page label range the class offers following method:
Description
Add a page label range.
Parameters
- $startPage : integer
The page index to start the page label range
- $style : string
The page label style. See
SetaPDF_Core_Document_Catalog_PageLabels::STYLE_XXX
constants- $prefix : string
A page label prefix
- $firstPageValue : integer
The value of the numeric portion for the first page in the range
- $encoding : string
The input encoding
Exceptions
Throws SetaPDF_Core_DataStructure_Tree_KeyAlreadyExistsException
Throws SetaPDF_Core_SecHandler_Exception
Throws SetaPDF_Core_Type_Exception
Following PHP script will add several page label ranges to a new document with 100 blank pages: