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

Import and Export

ComPDF SDK supports importing and exporting form data in xfdf format to facilitate the management of data in PDF documents.

Import Forms

Imports the form data from the specified XFDF file into the current PDF document.

The API only imports form data and modifies the form content through the corresponding form name.

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

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

const xfdfFile = '/data/user/0/com.compdfkit.reactnative.example/xxx/xxx.xfdf';
// or use Uri on the Android Platform.
const xfdfFile = 'content://xxxx';
const result = await pdfReaderRef.current.importWidgets(xfdfFile);

Export Forms

exports the form data from the current PDF document to an XFDF file.

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

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

const exportXfdfFilePath = await pdfReaderRef.current?.exportWidgets();