2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

Merge pull request #229 from ankitsinghaniyaz/master

Fix font issue in invoice
This commit is contained in:
Alan 2021-10-28 21:45:41 +05:30 committed by GitHub
commit 2e6733f58b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 16 deletions

View File

@ -90,7 +90,13 @@ module.exports = {
{
fieldname: 'font',
label: 'Font',
fieldtype: 'AutoComplete',
fieldtype: 'Select',
options: [
'Inter',
'Times New Roman',
'Arial',
'Courier'
],
default: 'Inter'
}
],
@ -99,6 +105,7 @@ module.exports = {
'displayLogo',
'template',
'color',
'font',
'email',
'phone',
'address',

View File

@ -1,5 +1,8 @@
<template>
<div class="border h-full">
<div
class="bg-white border h-full"
:style="{ 'font-family': printSettings.font }"
>
<div>
<div class="px-6 pt-6" v-if="printSettings">
<div class="flex text-sm text-gray-900 border-b pb-4">

View File

@ -48,10 +48,10 @@ export async function loadExistingDatabase() {
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]) {
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;
let printWindow = new BrowserWindow({
@ -246,16 +246,17 @@ export function makePDF(html, destination) {
printBackgrounds: true,
printSelectionOnly: false
};
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));
});
const sleep = m => new Promise(r => setTimeout(r, m));
printWindow.webContents.on('did-finish-load', async () => {
injectCSS(printWindow.webContents);
await sleep(1000);
printWindow.webContents.printToPDF(printOptions).then(data => {
printWindow.close();
fs.writeFile(destination, data, error => {
if (error) throw error;
return (shell.openItem(destination));
});
});
});