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);
}