From 40973dc4fef98d0fbde2d157af366eea96c3af4a Mon Sep 17 00:00:00 2001 From: Alexey Koshelev Date: Thu, 27 Mar 2025 15:31:46 +0300 Subject: [PATCH] [PDFE] Add select printer and print using the system dialog --- apps/pdfeditor/main/app/controller/Print.js | 27 ++- .../pdfeditor/main/app/view/FileMenuPanels.js | 210 +++++++++++++++--- 2 files changed, 200 insertions(+), 37 deletions(-) diff --git a/apps/pdfeditor/main/app/controller/Print.js b/apps/pdfeditor/main/app/controller/Print.js index b8c1df2b2d..77aced2af4 100644 --- a/apps/pdfeditor/main/app/controller/Print.js +++ b/apps/pdfeditor/main/app/controller/Print.js @@ -43,7 +43,11 @@ define([ this.adjPrintParams = new Asc.asc_CAdjustPrint(); this._state = { lock_doc: false, - firstPrintPage: 0 + firstPrintPage: 0, + pgorient: true, + isPrinterInfoLoad: false, + currentPrinter: null, + printersList: [] }; this._navigationPreview = { @@ -75,7 +79,8 @@ define([ onAfterRender: function(view) { var me = this; this.printSettings.menu.on('menu:hide', _.bind(this.onHidePrintMenu, this)); - this.printSettings.btnPrint.on('click', _.bind(this.onBtnPrint, this, true)); + this.printSettings.btnPrintSystemDialog.on('click', _.bind(this.onBtnPrint, this, true, true)); + this.printSettings.btnPrint.on('click', _.bind(this.onBtnPrint, this, true, false)); this.printSettings.btnPrintPdf.on('click', _.bind(this.onBtnPrint, this, false)); this.printSettings.btnPrevPage.on('click', _.bind(this.onChangePreviewPage, this, false)); this.printSettings.btnNextPage.on('click', _.bind(this.onChangePreviewPage, this, true)); @@ -129,6 +134,10 @@ define([ return me.txtPrintRangeInvalid; }; + if(this._state.isPrinterInfoLoad) { + this.printSettings.updateCmbPrinter(this._state.currentPrinter, this._state.printersList); + } + Common.NotificationCenter.on('window:resize', _.bind(function () { if (this._isPreviewVisible) { this.api.asc_drawPrintPreview(this._navigationPreview.currentPreviewPage); @@ -398,6 +407,15 @@ define([ Common.NotificationCenter.trigger('edit:complete'); }, + setPrinterInfo: function(currentPrinter, list) { + this._state.isPrinterInfoLoad = true; + this._state.currentPrinter = currentPrinter; + this._state.printersList = list; + if(this.printSettings) { + this.printSettings.updateCmbPrinter(this._state.currentPrinter, this._state.printersList); + } + }, + checkPageSize: function(width, height, left, right, top, bottom) { var section = this.api.asc_GetSectionProps(); (width===undefined) && (width = parseFloat(section.get_W().toFixed(4))); @@ -512,7 +530,7 @@ define([ this.printSettings.btnNextPage.setDisabled(curPage > pageCount - 2); }, - onBtnPrint: function(print) { + onBtnPrint: function(print, useSystemDialog) { this._isPrint = print; if (this.printSettings.cmbRange.getValue()===-1 && this.printSettings.inputPages.checkValidate() !== true) { this.printSettings.inputPages.focus(); @@ -525,7 +543,10 @@ define([ this._state.firstPrintPage = this._navigationPreview.currentPage; var size = this.api.asc_getPageSize(this._state.firstPrintPage); + var printerOption = this.printSettings.cmbPrinter.getSelectedRecord(); this.adjPrintParams.asc_setNativeOptions({ + usesystemdialog: useSystemDialog, + printer: printerOption ? printerOption.value : null, pages: this.printSettings.cmbRange.getValue()===-1 ? this.printSettings.inputPages.getValue() : this.printSettings.cmbRange.getValue(), paperSize: { w: size ? size['W'] : undefined, diff --git a/apps/pdfeditor/main/app/view/FileMenuPanels.js b/apps/pdfeditor/main/app/view/FileMenuPanels.js index 3d06a7ded2..cb20ae044c 100644 --- a/apps/pdfeditor/main/app/view/FileMenuPanels.js +++ b/apps/pdfeditor/main/app/view/FileMenuPanels.js @@ -2315,22 +2315,25 @@ define([], function () { '
<%= scope.txtPrint %>
', '', '', - '', + '', + '', + '', '', '', - '', + '', '', - '', + '', '', - '', + '', '', - '', + '', '', + '', '
', '', - '', - '', + '', + '', '
<%= scope.txtPages %>:
<%= scope.txtCopies %>:
<%= scope.txtPages %>:
<%= scope.txtCopies %>:
', '
', '