mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
format document
This commit is contained in:
parent
fd8221a576
commit
87c944cd4f
@ -1 +1 @@
|
||||
import './styles/index.css';
|
||||
import './styles/index.css';
|
||||
|
19
src/utils.js
19
src/utils.js
@ -209,9 +209,9 @@ export function handleErrorWithDialog(e, doc) {
|
||||
// NOTE: a hack to find all the css from the current document and inject it to the print version
|
||||
// remove this if you are able to fix and get the default css loading on the page
|
||||
function injectCSS(contents) {
|
||||
const styles = document.getElementsByTagName('style')
|
||||
const styles = document.getElementsByTagName('style');
|
||||
|
||||
for(let style of styles) {
|
||||
for (let style of styles) {
|
||||
contents.insertCSS(style.innerHTML);
|
||||
}
|
||||
}
|
||||
@ -259,14 +259,13 @@ export function makePDF(html, destination) {
|
||||
return new Promise(resolve => {
|
||||
printWindow.webContents.on('did-finish-load', () => {
|
||||
injectCSS(printWindow.webContents);
|
||||
printWindow.webContents.printToPDF(printOptions)
|
||||
.then(data => {
|
||||
printWindow.close();
|
||||
fs.writeFile(destination, data, error => {
|
||||
if (error) throw error;
|
||||
resolve(shell.openItem(destination));
|
||||
});
|
||||
})
|
||||
printWindow.webContents.printToPDF(printOptions).then(data => {
|
||||
printWindow.close();
|
||||
fs.writeFile(destination, data, error => {
|
||||
if (error) throw error;
|
||||
resolve(shell.openItem(destination));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user