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:
- UI Switching: Select the mode from the mode switch menu in the upper-right corner of CPDFReaderView.
- Initialization Setting: Define the initial mode in CPDFConfiguration.
- 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);