1// config.js
2const { documentViewer, annotationManager } = instance.Core;
3
4documentViewer.addEventListener('documentLoaded', async () => {
5  const doc = documentViewer.getDocument();
6  const pagesToExtract = [2, 3];
7
8  // only include annotations on the pages to extract
9  const annotList = annotationManager.getAnnotationsList().filter(annot => pagesToExtract.indexOf(annot.PageNumber) > -1);
10  const xfdfString = await annotationManager.exportAnnotations({ annotList });
11  const data = await doc.extractPages(pagesToExtract, xfdfString);
12  const arr = new Uint8Array(data);
13
14  //optionally save the blob to a file or upload to a server
15  const blob = new Blob([arr], { type: 'application/pdf' });
16});