- Getting Started
- Memory Usage
- Readers and Writers
- The Document Class
- Page Layout and Mode
- Viewer Preferences
- Document Outline
- Page Labels
- 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
Annotations Access, edit and create annotations
Table of Contents
The PDF format allows you to associate objects such as a note, or a link with a location on a page of a PDF document. This is done with annotations. The PDF format includes a wide variety of standard annotation types. The SetaPDF-Core component allows you to access all types of annotations at a deep level but also comes with high level implementations allowing almost full control over annotation objects.
$pages = $document->getCatalog()->getPages(); $page = $pages->getPage(1); $annotations = $page->getAnnotations();
This helper instance offers various methods to get instances of attached annotations:
Get all annotations of this page.
Get an annotation by its name (NM entry)
Or let you add or remove annotations:
Adds an annotation to the page.
Removes an annotation from the annotation array of the page.
The annotation types are specified in the PDF format (as subtypes) and are represented as constants in the SetaPDF_Core_Document_Page_Annotation class:
To e.g. only fetch link annotations you could use this line:
$links = $annotations->getAll(SetaPDF_Core_Document_Page_Annotation::TYPE_LINK);