From 5f4076ff0e4738134664f75108e34b980993452f Mon Sep 17 00:00:00 2001 From: Libor M Date: Sun, 2 Apr 2017 08:21:04 +0200 Subject: [PATCH] window parameter in open and print method (issue #587) --- src/browser-extensions/pdfMake.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/browser-extensions/pdfMake.js b/src/browser-extensions/pdfMake.js index 2087d64ca..3d5ef2c40 100644 --- a/src/browser-extensions/pdfMake.js +++ b/src/browser-extensions/pdfMake.js @@ -95,8 +95,10 @@ Document.prototype._openWindow = function () { return win; }; -Document.prototype._openPdf = function (options) { - var win = this._openWindow(); +Document.prototype._openPdf = function (options, win) { + if (!win) { + win = this._openWindow(); + } try { this.getBlob(function (result) { var urlCreator = window.URL || window.webkitURL; @@ -109,19 +111,21 @@ Document.prototype._openPdf = function (options) { } }; -Document.prototype.open = function (options) { +Document.prototype.open = function (options, win) { options = options || {}; options.autoPrint = false; + win = win || null; - this._openPdf(options); + this._openPdf(options, win); }; -Document.prototype.print = function (options) { +Document.prototype.print = function (options, win) { options = options || {}; options.autoPrint = true; + win = win || null; - this._openPdf(options); + this._openPdf(options, win); }; Document.prototype.download = function (defaultFileName, cb, options) {