define(["require", "exports", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function onSaveClicked() {
var _this = this;
this.isSkipRevert = true;
this.showOrganizeLoadingIndicator(true);
if ((JSON.stringify(this.tempOrganizePagesCollection) !== JSON.stringify(this.organizePagesCollection)) ||
this.isDocumentModified) {
this.updateOrganizePageCollection();
this.totalCheckedCount = 0;
this.isDocumentModified = true;
var pdfBlob_1;
this.pdfViewer.saveAsBlob().then(function (blob) {
pdfBlob_1 = blob;
_this.pdfViewerBase.blobToBase64(pdfBlob_1).then(function (base64) {
if (!ej2_base_1.isNullOrUndefined(base64) && base64 !== '') {
var fileName = _this.pdfViewer.fileName;
var downloadFileName = _this.pdfViewer.downloadFileName;
var jsonDocumentId = _this.pdfViewerBase.jsonDocumentId;
_this.showOrganizeLoadingIndicator(false);
_this.organizeDialog.hide();
_this.undoOrganizeCollection = [];
_this.redoOrganizeCollection = [];
_this.pdfViewer.loadDocInternally(base64, null, false);
_this.pdfViewerBase.updateDocumentEditedProperty(true);
_this.pdfViewer.fileName = fileName;
if (!ej2_base_1.isNullOrUndefined(downloadFileName)) {
_this.pdfViewer.downloadFileName = downloadFileName;
}
else {
_this.pdfViewer.downloadFileName = fileName;
}
_this.pdfViewerBase.jsonDocumentId = jsonDocumentId;
_this.isOrganizeWindowOpen = false;
_this.pdfViewer.isPageOrganizerOpen = false;
}
});
});
}
else {
this.showOrganizeLoadingIndicator(false);
this.organizeDialog.hide();
this.undoOrganizeCollection = [];
this.redoOrganizeCollection = [];
this.isOrganizeWindowOpen = false;
this.pdfViewer.isPageOrganizerOpen = false;
}
}
exports.onSaveClicked = onSaveClicked;
function onSaveasClicked() {
var _this = this;
if (JSON.stringify(this.tempOrganizePagesCollection) !== JSON.stringify(this.organizePagesCollection)) {
this.updateOrganizePageActions();
}
var fileName = this.pdfViewer.fileName;
var pdfBlob;
var canDownload = false;
var temp = JSON.parse(JSON.stringify(this.organizePagesCollection));
this.pdfViewer.saveAsBlob().then(function (blob) {
pdfBlob = blob;
var conversionPromise = _this.pdfViewerBase.clientSideRendering
? _this.pdfViewerBase.blobToByteArray(pdfBlob)
: _this.pdfViewerBase.blobToBase64(pdfBlob);
conversionPromise.then(function (result) {
if (!ej2_base_1.isNullOrUndefined(result) && result !== '') {
canDownload = _this.pdfViewer.firePageOrganizerSaveAsEventArgs(fileName, result);
if (canDownload) {
_this.pdfViewerBase.fileDownload(result, _this.pdfViewerBase, true);
_this.organizePagesCollection = JSON.parse(JSON.stringify(temp));
}
}
});
});
}
exports.onSaveasClicked = onSaveasClicked;
function updateOrganizePageActions() {
this.updateOrganizePageCollection();
this.totalCheckedCount = 0;
this.isDocumentModified = true;
this.pdfViewerBase.updateDocumentEditedProperty(true);
}
exports.updateOrganizePageActions = updateOrganizePageActions;
});
|