diff --git a/app/pdf.js b/app/pdf.js index 76d26f4a296..314beda21ec 100644 --- a/app/pdf.js +++ b/app/pdf.js @@ -6,14 +6,14 @@ const electron = require('electron') const BrowserWindow = electron.BrowserWindow +const Tabs = require('./browser/tabs') +const {fileUrl} = require('../js/lib/appUrlUtil') const renderUrlToPdf = (appState, action, testingMode) => { let url = action.url let savePath = action.savePath let openAfterwards = action.openAfterwards - let currentBw = BrowserWindow.getFocusedWindow() - let bw = new BrowserWindow({show: !!testingMode, backgroundColor: '#ffffff'}) let wv = bw.webContents @@ -41,15 +41,15 @@ const renderUrlToPdf = (appState, action, testingMode) => { if (state === 'completed') { let finalSavePath = item && item.getSavePath() - if (openAfterwards && savePath) { - currentBw.webContents.loadURL('file://' + finalSavePath) - } - if (bw && !testingMode) { try { bw.close() } catch (exc) {} } + + if (openAfterwards && finalSavePath) { + Tabs.create({url: fileUrl(finalSavePath)}) + } } }) }) diff --git a/js/about/aboutActions.js b/js/about/aboutActions.js index 3dda621c60c..14cb50757fb 100644 --- a/js/about/aboutActions.js +++ b/js/about/aboutActions.js @@ -364,11 +364,12 @@ const aboutActions = { /** * Dispatches a message to render a URL into a PDF file */ - renderUrlToPdf: function (url, savePath) { + renderUrlToPdf: function (url, savePath, openAfterwards) { aboutActions.dispatchAction({ actionType: appConstants.APP_RENDER_URL_TO_PDF, url: url, - savePath: savePath + savePath: savePath, + openAfterwards: openAfterwards }) } } diff --git a/js/about/contributionStatement.js b/js/about/contributionStatement.js index 18343a44edd..8a10af56dcf 100644 --- a/js/about/contributionStatement.js +++ b/js/about/contributionStatement.js @@ -127,7 +127,7 @@ class ContributionStatement extends ImmutableComponent { } renderPdf () { - aboutActions.renderUrlToPdf(this.htmlDataURL, this.receiptFileName()) + aboutActions.renderUrlToPdf(this.htmlDataURL, this.receiptFileName(), true) } get transaction () {