Skip to content

Commit

Permalink
💢 Add physical printing, bump
Browse files Browse the repository at this point in the history
  • Loading branch information
albertzak committed Aug 17, 2020
1 parent 18b826e commit aefa8dd
Show file tree
Hide file tree
Showing 4 changed files with 3,708 additions and 8 deletions.
21 changes: 17 additions & 4 deletions app/electron/main/print.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
const fs = require('fs')
const path = require('path')
const temp = require('temp')
const pdfToPrinter = require('pdf-to-printer')
const { shell, ipcMain } = require('electron')
const logger = require('./logger')

const start = (options) => {
temp.track()
ipcMain.on('print', (e, printOptions) => {
options.title = printOptions.title
console.log(options.title)
print(options)

const { title, physical, printer, flags, localPath } = printOptions
if (physical && localPath) {
const args = {
printer,
win32: flags
}

console.log(`[print] physical file "${localPath}" on printer "${printer}" with flags ${JSON.stringify(args)}`)
pdfToPrinter(localPath, args)
} else {
options.title = title
console.log(options.title)
printToPdf(options)
}
})
}

const print = (options) => {
const printToPdf = (options) => {
temp.mkdir('rosalind', (err, tmpDir) => {
if (err) { return logger.error(err) }
const pdfPath = path.join(tmpDir, (options.title || 'Print') + '.pdf')
Expand Down
Loading

0 comments on commit aefa8dd

Please sign in to comment.