UNPKG

@syncfusion/ej2-pdfviewer

Version:
91 lines (90 loc) 3.63 kB
import { isNullOrUndefined } from '@syncfusion/ej2-base'; /** * @private * @returns { void } */ export 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 (!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 (!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; } } /** * @private * @returns { void } */ export 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 (!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)); } } }); }); } /** * @private * @returns { void } */ export function updateOrganizePageActions() { this.updateOrganizePageCollection(); this.totalCheckedCount = 0; this.isDocumentModified = true; this.pdfViewerBase.updateDocumentEditedProperty(true); }