Skip to content

Commit

Permalink
Fix printing to pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
albertzak committed Jun 21, 2022
1 parent 88f0132 commit 9af1076
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions app/electron/main/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion app/electron/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "rosalind",
"productName": "Rosalind",
"version": "0.0.262",
"version": "0.0.263",
"private": true,
"description": "Rosalind",
"author": {
Expand Down

0 comments on commit 9af1076

Please sign in to comment.