Skip to content

Content Editor Mode

Before performing content editing in CPDFReaderView, you need to switch to CPDFViewMode.contentEditor mode.

You can switch modes in the following ways:

  1. UI Switching: Select the mode from the mode switch menu in the upper-right corner of CPDFReaderView.
  2. Initialization Setting: Define the initial mode in CPDFConfiguration.
  3. Runtime Switching: Switch modes programmatically using the CPDFReaderView API.
tsx
// Set content editing mode on initialization
const pdfReaderRef = useRef<CPDFReaderView>(null);

<CPDFReaderView
  ref={pdfReaderRef}
  document={samplePDF}
  configuration={ComPDFKit.getDefaultConfig({
    modeConfig: {
      initialViewMode: 'contentEditor'
    }
  })}
/>

// Switch to content editing mode programmatically
await pdfReaderRef.current?.setPreviewMode(CPDFViewMode.CONTENT_EDITOR);