save annotations

89 views
Skip to first unread message

Tehila Horvitz

unread,
Sep 20, 2016, 1:00:39 PM9/20/16
to PDFTron WebViewer
 Annotations / Signature Save Issues
 

.I having troubles saving the signature/annotations. Any ideas why can't we save it/them
When I Rotate and Remove The page is saving but Annotations didn't save
Here is the code
Who can help me

thank

  return regeneratorRuntime.wrap(function main$(context$3$0) {
                while (1) switch (context$3$0.prev = context$3$0.next) {
 case 0:
                        ret = 0;
                        context$3$0.prev = 1;
                        islocked = false;
                        doc = pdfDoc;
                        doc.lock();
                        islocked = true;
                        doc.initSecurityHandler();

                        context$3$0.next = 9;
                        return doc.saveMemoryBuffer(PDFNet.SDFDoc.SaveOptions.e_linearized);
                       
                    case 9:
                        docbuf = context$3$0.sent;
                      
                        callToWebService(docbuf, "ActionDocumentService.svc/json/UploadFromPDFToDocumntum");
                        doc.unlock();
                        context$3$0.next = 46;
                        break;
                    case 46:
                        console.log("Done.");
                        context$3$0.next = 53;
                        break;
                    case 49:
                        context$3$0.prev = 49;
                        context$3$0.t1 = context$3$0["catch"](1);
                        console.log(context$3$0.t1.stack)
                        ret = 1;
                    case 53:
                        return context$3$0.abrupt("return", ret);
                    case 54:
                    case "end":
                        return context$3$0.stop();
                }
            }, marked2$0[1], this, [[1, 49]]);
        }

        return PDFNet.runGeneratorWithCleanup(main());
    }

    function callToWebService(data, wsURL, onSuccess, onError, async) {

        var isAsync = async != null && async == false ? async : true;

        


        var result= bufferToBase64(data);

        var object = {
            ActionDocumentId: window.parent.docId,
            Body: result,
            FileName: window.parent.fileName,
            FolderUrl: window.parent.filePath,
            version: window.parent.version
        }

        $.support.cors = true;
        $.ajax({
            url: "http://" + window.parent.serverName + ":8080" + "/" + "ActionDocumentService.svc/json/UploadFromPDFToDocumntum",
            type: "POST",
            async: isAsync,
            dataType: "json",
            contentType: "application/json",
            data: JSON.stringify(object),
            crossDomain: true,
            processdata: true,
            success: function (data) {
                if (data != null)
                 //   onSuccess(data);
                    //  setTimeout($.unblockUI, 50);
                    alert("המסמך נשמר");
            },
            error: function (error) {
                if (onError != null) {
                    alert("error.statusText");
                }
                else {
                    alert(error.statusText);
                    //setTimeout($.unblockUI, 50);
                }
            }
        });
    }

    function bufferToBase64(buf) {
        var binstr = Array.prototype.map.call(buf, function (ch) {
            return String.fromCharCode(ch);
        }).join('');
        return btoa(binstr);
    }
 

 

Ryan - PDFNet Developer

unread,
Sep 20, 2016, 4:42:11 PM9/20/16
to PDFTron WebViewer
When you add annotations using WebViewer, it does not modify the PDF itself, instead keeping the data separate. This is convenient, as you can just upload the annotations to your server, and not the entire PDF.

To save the annotations to the PDF try the following.

var doc = readerControl.docViewer.getDocument();
var annotManager = readerControl.docViewer.getAnnotationManager();
var options = {"xfdfString": annotManager.exportAnnotations()};
doc.getFileData(options).then(function(data) {
  // data is array
});


Reply all
Reply to author
Forward
0 new messages