From 9af107609cee93ff95d734d1c117ee3ffd18b8e2 Mon Sep 17 00:00:00 2001 From: Albert Zak Date: Tue, 21 Jun 2022 14:06:38 +0200 Subject: [PATCH] Fix printing to pdf --- app/electron/main/print.js | 11 +++-------- app/electron/package.json | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/electron/main/print.js b/app/electron/main/print.js index 938d5f1b..ee0825ab 100644 --- a/app/electron/main/print.js +++ b/app/electron/main/print.js @@ -2,7 +2,7 @@ const fs = require('fs') const path = require('path') const temp = require('temp') const pdfToPrinter = require('pdf-to-printer') -const { shell, ipcMain } = require('electron') +const { shell, ipcMain, webContents } = require('electron') const logger = require('./logger') const start = (options) => { @@ -68,12 +68,7 @@ const printToPdf = (options) => { } logger.info('print calling ipcReceiver.printToPDF') - options.ipcReceiver.printToPDF(printOptions, (err, data) => { - if (err) { - logger.error('[Print] Failed to generate pdf: ' + err) - return - } - + webContents.getFocusedWebContents().printToPDF(printOptions).then(data => { logger.info('print writing file') fs.writeFile(pdfPath, data, (err) => { if (err) { @@ -83,7 +78,7 @@ const printToPdf = (options) => { logger.info('[Print] Saved pdf to path: ' + pdfPath) logger.info('print opening file') - const ok = shell.openItem(pdfPath) + const ok = shell.openPath(pdfPath) if (!ok) { logger.error('[Print] failed to open pdf: ' + pdfPath) } diff --git a/app/electron/package.json b/app/electron/package.json index f9d0f4c8..2ee9f073 100644 --- a/app/electron/package.json +++ b/app/electron/package.json @@ -1,7 +1,7 @@ { "name": "rosalind", "productName": "Rosalind", - "version": "0.0.262", + "version": "0.0.263", "private": true, "description": "Rosalind", "author": {