For the complete documentation index, see llms.txt. This page is also available as Markdown.

Export annotations using JavaScript

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

async function main() {
  const doc = await PDFNet.PDFDoc.createFromURL(filename);

  // Extract annotations to FDF.
  // Optionally use e_both to extract both forms and annotations
  const doc_fields = await doc.fdfExtract(PDFNet.PDFDoc.ExtractFlag.e_annots_only); //PDFNet.PDFDoc.ExtractFlag.e_forms_only

  // Export annotations from FDF to XFDF.
  const xfdf_data = await doc_fields.saveAsXFDFAsString();

  //optionally save the blob to a file or upload to a server
  const blob = new Blob([xfdf_data], { type: 'application/xml' });
}
PDFNet.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)

Last updated

Was this helpful?