Skip to content
DemoAPI ReferenceFAQ

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub
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();