Show and hide existing annotations in Android
By default, PDFViewCtrl shows all annotations on PDF document. If you want to hide a particular annotation on PDFViewCtrl, or hide all annotations on PDFViewCtrl, you can hide annotations as follows:
Show and hide one annotation
To show a hidden annotation in PDFViewCtrl, call showAnnotation(Annot):
public static void showAnnotation(PDFViewCtrl pdfViewCtrl, Annot annot, int annotPageNum) {
pdfViewCtrl.showAnnotation(annot);
pdfViewCtrl.update(annot, annotPageNum);
}fun showAnnotation(pdfViewCtrl: PDFViewCtrl, annot: Annot, annotPageNum: Int) {
pdfViewCtrl.showAnnotation(annot)
pdfViewCtrl.update(annot, annotPageNum)
}To hide an annotation in PDFViewCtrl, call hideAnnotation(Annot).
public static void hideAnnotation(PDFViewCtrl pdfViewCtrl, Annot annot, int annotPageNum) {
pdfViewCtrl.hideAnnotation(annot);
pdfViewCtrl.update(annot, annotPageNum);
}fun hideAnnotation(pdfViewCtrl: PDFViewCtrl, annot: Annot, annotPageNum: Int) {
pdfViewCtrl.hideAnnotation(annot)
pdfViewCtrl.update(annot, annotPageNum)
}Show and hide all annotations
Alternatively, you can show/hide all annotations in PDFViewCtrl by calling setDrawAnnotations(boolean). This method toggles the visibility of annotations and form fields.
For example, disabling all annotations and form fields from rendering:
try {
pdfViewCtrl.setDrawAnnotations(false);
pdfViewCtrl.update(true);
} catch (PDFNetException e) {
e.printStackTrace();
}try {
pdfViewCtrl?.setDrawAnnotations(false)
pdfViewCtrl?.update(true)
} catch (e : PDFNetException) {
e.printStackTrace()
}Last updated
Was this helpful?