Christian Burgos
Christian Burgos

Reputation: 1591

pdftron webviewer - how to save the whole edited pdf to server with php

I am currently a developing an application that is using a PDFTron webviewer. Is there anyway to save the edited pdf edited with pdftron webviewer to the server?

There is a feature of pdftron that saves annotations to the server, but I need to save the whole pdf with the edits to the server.

Upvotes: 2

Views: 1911

Answers (1)

mparizeau
mparizeau

Reputation: 663

You could call the following function from a WebViewer config file to get the PDF data as a blob. Once you have the blob you can refer to one of the many examples online of how to upload a blob to a server.

function uploadPDF() {
  var docViewer = readerControl.docViewer;

  var options = {
    xfdfString: docViewer.getAnnotationManager().exportAnnotations()
  };
  var doc = docViewer.getDocument();
  doc.getFileData(options).then(function(data) {
    var arr = new Uint8Array(data);
    var blob = new Blob([arr], {
        type: 'application/pdf'
    });

    // upload blob here
  });
}

Upvotes: 7

Related Questions