How can I help you?
PdfAnnotationCollection
21 Apr 20263 minutes to read
The class provides methods and properties to handle the collection of PdfAnnotation.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Access annotation coolection from first page
let annotations: PdfAnnotationCollection = document.getPage(0).annotations;
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();Properties
Get count number
Gets the annotation count (Read only).
Methods
add
Add a new PdfAnnotation into the collection.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Access first page
let page: PdfPage = document.getPage(0);
// Add a new annotation into the collection
page.annotations.add(annotation);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();| Parameter | Type | Description |
|---|---|---|
| annotation | PdfAnnotation |
Annotation to add. |
Returns number
at
Gets the PdfAnnotation at the specified index.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Access first page
let page: PdfPage = document.getPage(0);
// Access the annotation at index 0
let annotation: PdfAnnotation = page.annotations.at(0);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();| Parameter | Type | Description |
|---|---|---|
| index | number |
Field index. |
Returns PdfAnnotation
remove
Remove an annotation from the collection.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Access first page
let page: PdfPage = document.getPage(0);
// Access first annotation from the PDF page
let annotation: PdfAnnotation = page.annotations.at(0);
// Remove an annotation from the collection
page.annotations.remove(annotation);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();| Parameter | Type | Description |
|---|---|---|
| annotation | PdfAnnotation |
Annotation to remove. |
Returns void
removeAt
Remove an annotation from the collection at the specified index.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Access first page
let page: PdfPage = document.getPage(0);
// Remove an annotation from the collection
page.annotations.removeAt(0);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();| Parameter | Type | Description |
|---|---|---|
| index | number |
Annotation index. |
Returns void