Skip to content
ComPDF
DemoAPI ReferenceFAQ
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

Guides

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={ComPDF.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('ComPDFRN saveDocument');
}

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