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