saving edited pdf to server with php

286 views
Skip to first unread message

Christian Joy Burgos

unread,
Aug 19, 2016, 12:30:19 PM8/19/16
to PDFTron WebViewer
is it possible to save edited pdfs to server through php?

Matt Parizeau

unread,
Aug 22, 2016, 4:28:57 PM8/22/16
to pdfnet-w...@googlegroups.com
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 doc = docViewer.getDocument();
  var annotManager = docViewer.getAnnotationManager();

  docViewer.getAnnotationsLoadedPromise().then(function() {
    var options = { 'xfdfString': annotManager.exportAnnotations(), 'flags': CoreControls.SaveOptions.LINEARIZED };
    doc.getFileData(options).then(function (data) {
      var arr = new Uint8Array(data);
      var blob = new Blob([arr], {
        type: 'application/pdf'
      });
      // post blob to the url
    });
  });
}

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages