Show/hide annotations

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/hide an annotation on PDFViewCtrl.

To show a hidden annotation on PDFViewCtrl, call showAnnotation(Annot):

public static void showAnnotation(PDFViewCtrl pdfViewCtrl, Annot annot, int annotPageNum) {
  pdfViewCtrl.showAnnotation(annot);
  pdfViewCtrl.update(annot, annotPageNum);
}

To hide an annotation on PDFViewCtrl, call hideAnnotation(Annot).

public static void hideAnnotation(PDFViewCtrl pdfViewCtrl, Annot annot, int annotPageNum) {
  pdfViewCtrl.hideAnnotation(annot);
  pdfViewCtrl.update(annot, annotPageNum);
}
After hide/show an annotation on PDFViewCtrl, You must call update(Annot, int) to redraw the area covered with the given annotation.

Show/hide all annotations on PDFViewCtrl.

Alternatively, you can show/hide all annotations on PDFViewCtrl by calling setDrawAnnotations(boolean). This method enables or disables annotations and forms from rendering.

For example, disabling annotations from rendering:

try {
    pdfViewCtrl.setDrawAnnotations(false);
    pdfViewCtrl.update(true);
} catch (PDFNetException e) {
    e.printStackTrace();
}
After enabling/disabling annotations from rendering on PDFViewCtrl, You must call update(boolean) to redraw the pdf content.