removePageAnnotation
Deletes an existing annotation from a specified page.
Signature
removePageAnnotation(
doc: PdfDocumentObject,
page: PdfPageObject,
annotation: PdfAnnotationObject
): PdfTask<boolean>;Description
This method finds and permanently removes an annotation from the PDF document in memory. The annotation is identified by its id property.
To persist this change, you must call saveAsCopy to generate a new PDF file without the deleted annotation.
Parameters
| Name | Type | Description |
|---|---|---|
doc | PdfDocumentObject | The handle of the document to modify. |
page | PdfPageObject | The page where the annotation exists. |
annotation | PdfAnnotationObject | The annotation object to remove. Only the id property is used for identification. |
Returns
PdfTask<boolean>
A Task that resolves with true if the annotation was successfully found and removed.
Example
// Assuming 'engine', 'document', and 'page' are available
async function deleteAnnotation(annotationToDelete) {
try {
const success = await engine.removePageAnnotation(document, page, annotationToDelete).toPromise();
if (success) {
console.log(`Annotation ${annotationToDelete.id} was successfully removed.`);
// Re-render the page to reflect the change
}
} catch (error) {
console.error('Failed to remove annotation:', error);
}
}See Also
Last updated on October 27, 2025
Need Help?
Join our community for support, discussions, and to contribute to EmbedPDF's development.