Deleting annotations in Android
Using the Apryse library, you can delete a single annotation, delete all the annotations on a page, or delete all the annotations in a PDF document.
Delete an annotation
You can delete an annotation as follows:
public void deleteAnnotation(final PDFViewCtrl pdfViewCtrl, final Annot annot, final int pageNum) throws Exception {
// Lock the document first, because accessing annotation/doc information isn't thread-safe.
pdfViewCtrl.docLock(true, new PDFViewCtrl.LockRunnable() {
@Override
public void run() throws Exception {
Page page = pdfViewCtrl.getDoc().getPage(pageNum);
page.annotRemove(annot);
pdfViewCtrl.update(annot, pageNum);
}
});
}fun deleteAnnotation(pdfViewCtrl: PDFViewCtrl, annot: Annot?, pageNum: Int) {
// Lock the document first, because accessing annotation/doc information isn't thread-safe.
pdfViewCtrl.docLock(true) {
val page = pdfViewCtrl.doc.getPage(pageNum)
page.annotRemove(annot)
pdfViewCtrl.update(annot, pageNum)
}
}Delete all annotations on a page
The following snippet shows how to enumerate all the annotations on a page, as well as how to delete them.
Delete all the annotations in a PDF document
The following snippet shows how to traverse all the pages in a PDF document and delete all the annotations.
Last updated
Was this helpful?