Export annotations using JavaScript

To extract data from PDF to FDF, then export FDF as XFDF

JavaScript

1async function main() {
2 const doc = await PDFNet.PDFDoc.createFromURL(filename);
3
4 // Extract annotations to FDF.
5 // Optionally use e_both to extract both forms and annotations
6 const doc_fields = await doc.fdfExtract(PDFNet.PDFDoc.ExtractFlag.e_annots_only); //PDFNet.PDFDoc.ExtractFlag.e_forms_only
7
8 // Export annotations from FDF to XFDF.
9 const xfdf_data = await doc_fields.saveAsXFDFAsString();
10
11 //optionally save the blob to a file or upload to a server
12 const blob = new Blob([xfdf_data], { type: 'application/xml' });
13}
14PDFNet.runWithCleanup(main);

PDF Form Fill and Form Data Extraction
Full sample code which illustrates basic FDF merge/extract functionality and full support for FDF (Forms Data Format)

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales