Some test text!

menu
search

Get file data with WebViewer server

When using WebViewer Server, use the getFileData function to get a URL for downloading the document data. Afterward simply get a Blob object from the URL:

WebViewer(...)
  .then(function(instance) {
    var docViewer = instance.docViewer;
    var annotManager = instance.annotManager;

    docViewer.on('documentLoaded', function() {
      var doc = docViewer.getDocument();
      var options = {
        annots: annotManager.exportAnnotations()
      };

      doc.getFileData(options).then(function(data) {
        var xhr = new XMLHttpRequest();
        xhr.open('GET', data.url, true);
        xhr.responseType = 'blob';
        xhr.onload = function(e) {
          if (this.status == 200) {
            var blob = this.response;
            // add code for handling Blob here
            // window.saveAs(blob, 'downloaded.pdf');
          }
        };
        xhr.send();
      });
    });
  });

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

PDFTron Receives USD$71 Million Growth Investment Led By Silversmith Capital Partners

Learn more
close