mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-27 19:07:15 +08:00
Fix print to pdf functionality
This commit is contained in:
parent
2591fc7ff3
commit
3be72eee5c
2 changed files with 5 additions and 10 deletions
|
@ -80,6 +80,7 @@ export default class PrintWindow {
|
|||
contextIsolation: false,
|
||||
},
|
||||
});
|
||||
require("@electron/remote").require("@electron/remote/main").enable(this.browserWin.webContents);
|
||||
this.browserWin.removeMenu();
|
||||
fs.writeFileSync(tmpMessagesPath, `window.printMessages = ${printMessages}`);
|
||||
fs.writeFileSync(this.tmpFile, content);
|
||||
|
|
|
@ -7,7 +7,7 @@ win.addListener('page-title-updated', event => {
|
|||
});
|
||||
|
||||
global.printToPDF = async () => {
|
||||
const { filePath } = awaitrequire('@electron/remote').dialog.showSaveDialog({
|
||||
const { filePath } = await require('@electron/remote').dialog.showSaveDialog({
|
||||
defaultPath: `${win.getTitle()}.pdf`,
|
||||
});
|
||||
|
||||
|
@ -20,14 +20,8 @@ global.printToPDF = async () => {
|
|||
pageSize: 'Letter',
|
||||
printBackground: true,
|
||||
landscape: false,
|
||||
},
|
||||
(error, data) => {
|
||||
if (error) {
|
||||
require('@electron/remote').dialog.showErrorBox('An Error Occurred', `${error}`);
|
||||
return;
|
||||
}
|
||||
|
||||
fs.writeFileSync(filename, data);
|
||||
}).then(data => {
|
||||
fs.writeFileSync(filePath, data);
|
||||
}
|
||||
);
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue