Skip to content
ComPDF
Guides

Annotation Visibility

ComPDF SDK supports controlling the visibility of annotations in the current document using CPDFConfiguration or CPDFReaderView.

The following examples demonstrate how to show or hide annotations:

Using CPDFConfiguration to Control Annotation Visibility

tsx
<CPDFReaderView
  ref={pdfReaderRef}
  document={samplePDF}
  configuration={ComPDFKit.getDefaultConfig({
    readerViewConfig: {
      annotationsVisible: true
    }
  })}
  />

Using CPDFReaderView to Control Annotation Visibility

tsx
// Check if annotations are currently visible
const visible = await pdfReaderRef.current?.isAnnotationsVisible();
// Show annotations
await pdfReaderRef.current?.setAnnotationsVisible(true);
// Hide annotations
await pdfReaderRef.current?.setAnnotationsVisible(false);