mirror of
https://github.com/frappe/books.git
synced 2025-02-09 07:29:07 +00:00
Merge pull request #229 from ankitsinghaniyaz/master
Fix font issue in invoice
This commit is contained in:
commit
2e6733f58b
@ -90,7 +90,13 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
fieldname: 'font',
|
fieldname: 'font',
|
||||||
label: 'Font',
|
label: 'Font',
|
||||||
fieldtype: 'AutoComplete',
|
fieldtype: 'Select',
|
||||||
|
options: [
|
||||||
|
'Inter',
|
||||||
|
'Times New Roman',
|
||||||
|
'Arial',
|
||||||
|
'Courier'
|
||||||
|
],
|
||||||
default: 'Inter'
|
default: 'Inter'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -99,6 +105,7 @@ module.exports = {
|
|||||||
'displayLogo',
|
'displayLogo',
|
||||||
'template',
|
'template',
|
||||||
'color',
|
'color',
|
||||||
|
'font',
|
||||||
'email',
|
'email',
|
||||||
'phone',
|
'phone',
|
||||||
'address',
|
'address',
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="border h-full">
|
<div
|
||||||
|
class="bg-white border h-full"
|
||||||
|
:style="{ 'font-family': printSettings.font }"
|
||||||
|
>
|
||||||
<div>
|
<div>
|
||||||
<div class="px-6 pt-6" v-if="printSettings">
|
<div class="px-6 pt-6" v-if="printSettings">
|
||||||
<div class="flex text-sm text-gray-900 border-b pb-4">
|
<div class="flex text-sm text-gray-900 border-b pb-4">
|
||||||
|
29
src/utils.js
29
src/utils.js
@ -48,10 +48,10 @@ export async function loadExistingDatabase() {
|
|||||||
filters: [{ name: 'SQLite DB File', extensions: ['db'] }]
|
filters: [{ name: 'SQLite DB File', extensions: ['db'] }]
|
||||||
};
|
};
|
||||||
|
|
||||||
let { filePaths } = await remote.dialog.showOpenDialog(options);
|
let { filePaths } = await remote.dialog.showOpenDialog(options);
|
||||||
|
|
||||||
if (filePaths && filePaths[0]) {
|
if (filePaths && filePaths[0]) {
|
||||||
return filePaths[0]
|
return filePaths[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ function injectCSS(contents) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function makePDF(html, destination) {
|
export async function makePDF(html, destination) {
|
||||||
const { BrowserWindow } = remote;
|
const { BrowserWindow } = remote;
|
||||||
|
|
||||||
let printWindow = new BrowserWindow({
|
let printWindow = new BrowserWindow({
|
||||||
@ -246,16 +246,17 @@ export function makePDF(html, destination) {
|
|||||||
printBackgrounds: true,
|
printBackgrounds: true,
|
||||||
printSelectionOnly: false
|
printSelectionOnly: false
|
||||||
};
|
};
|
||||||
|
|
||||||
return new Promise(resolve => {
|
const sleep = m => new Promise(r => setTimeout(r, m));
|
||||||
printWindow.webContents.on('did-finish-load', () => {
|
|
||||||
injectCSS(printWindow.webContents);
|
printWindow.webContents.on('did-finish-load', async () => {
|
||||||
printWindow.webContents.printToPDF(printOptions).then(data => {
|
injectCSS(printWindow.webContents);
|
||||||
printWindow.close();
|
await sleep(1000);
|
||||||
fs.writeFile(destination, data, error => {
|
printWindow.webContents.printToPDF(printOptions).then(data => {
|
||||||
if (error) throw error;
|
printWindow.close();
|
||||||
resolve(shell.openItem(destination));
|
fs.writeFile(destination, data, error => {
|
||||||
});
|
if (error) throw error;
|
||||||
|
return (shell.openItem(destination));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user