kopia lustrzana https://github.com/inkstitch/inkstitch
Merge pull request #769 from inkstitch/lexelby/fix-save-print-pdf
fix save and print PDF buttonspull/792/head
commit
21a8da80e1
6
Makefile
6
Makefile
|
@ -1,8 +1,8 @@
|
|||
|
||||
dist: locales inx
|
||||
bin/build-python
|
||||
bin/build-electron
|
||||
bin/build-distribution-archives
|
||||
bash bin/build-python
|
||||
bash bin/build-electron
|
||||
bash bin/build-distribution-archives
|
||||
|
||||
distclean:
|
||||
rm -rf build dist inx locales *.spec *.tar.gz *.zip electron/node_modules electron/dist
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
if [ "$BUILD" = "windows" ]; then
|
||||
args="-w --ia32"
|
||||
|
@ -11,6 +12,6 @@ elif [ "$BUILD" = "osx" ]; then
|
|||
fi
|
||||
|
||||
cd electron
|
||||
npm install -g yarn
|
||||
which yarn > /dev/null 2>&1 || npm install -g yarn
|
||||
yarn --link-duplicates --pure-lockfile
|
||||
yarn run dist ${args}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
'use strict'
|
||||
|
||||
import {app, BrowserWindow} from 'electron'
|
||||
import {app, BrowserWindow, ipcMain, dialog, shell} from 'electron'
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var tmp = require('tmp');
|
||||
|
||||
const url = require('url')
|
||||
|
||||
|
@ -15,7 +18,7 @@ if (process.env.NODE_ENV === 'development') {
|
|||
process.argv.shift()
|
||||
process.argv.shift()
|
||||
} else {
|
||||
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
|
||||
global.__static = path.join(__dirname, '/static').replace(/\\/g, '\\\\')
|
||||
}
|
||||
|
||||
let mainWindow
|
||||
|
@ -69,6 +72,25 @@ app.on('activate', () => {
|
|||
}
|
||||
})
|
||||
|
||||
ipcMain.on('save-pdf', function (event, pageSize) {
|
||||
mainWindow.webContents.printToPDF({"pageSize": pageSize}, function(error, data) {
|
||||
dialog.showSaveDialog(mainWindow, {"defaultPath": "inkstitch.pdf"}, function(filename, bookmark) {
|
||||
if (typeof filename !== 'undefined')
|
||||
fs.writeFileSync(filename, data, 'utf-8');
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
ipcMain.on('open-pdf', function (event, pageSize) {
|
||||
mainWindow.webContents.printToPDF({"pageSize": pageSize}, function(error, data) {
|
||||
tmp.file({keep: true, discardDescriptor: true}, function(err, path, fd, cleanupCallback) {
|
||||
fs.writeFileSync(path, data, 'utf-8');
|
||||
shell.openItem(path);
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* Auto Updater
|
||||
*
|
||||
|
|
Ładowanie…
Reference in New Issue