Skip to content

Save Document

Manual Save

When using the CPDFReaderView component, the document is automatically saved during operations such as sharing, flattening, or adding watermarks. Additionally, you can manually save the document at any time. For example:

tsx
const CPDFReaderViewExampleScreen = () => {

  const pdfReaderRef = useRef<CPDFReaderView>(null);

  return (
    <View style={{flex : 1}}>
      <Button title='Save As' onPress={async ()=>{
          const success = await pdfReaderRef.current?.save();
        }}></Button>
      <CPDFReaderView
        ref={pdfReaderRef}
        document={samplePDF}
        configuration={ComPDFKit.getDefaultConfig({})}
        />
    </View>
  );
};

Save Callback

When creating CPDFReaderView, you can set a save listener to handle save events. For example:

tsx
const pdfReaderRef = useRef<CPDFReaderView>(null);

const saveDocument = () => {
    console.log('ComPDFKitRN saveDocument');
}

<CPDFReaderView
    ref={pdfReaderRef}
    document={samplePDF}
    saveDocument={saveDocument}
    configuration={ComPDFKit.getDefaultConfig({
    })}/>