Some test text!

Extracting pages from PDF

If the user only wants to download part of a document, the extractPages function can be used to download specific pages. For example:

viewerElement.addEventListener('documentLoaded', function() {   
  var docViewer = myWebViewer.getInstance().docViewer;
  var doc = docViewer.getDocument();
  var pagesToExtract = [2, 3];

  var annotManager = docViewer.getAnnotationManager();
  // only include annotations on the pages to extract
  var annotList = annotManager.getAnnotationsList().filter(function(annot) {
    return pagesToExtract.indexOf(annot.PageNumber) > -1;
  });
  var xfdfString = annotManager.exportAnnotations({ annotList: annotList });

  doc.extractPages(pagesToExtract, xfdfString).then(function(data) {
    var arr = new Uint8Array(data);
    var blob = new Blob([arr], { type: 'application/pdf' });

    // in this example we are using FileSaver.js library  'SaveAs' function but any technique to save a blob works
    saveAs(blob, 'downloaded.pdf');
  });
});

Get the answers you need: Support