2
0
mirror of https://github.com/frappe/books.git synced 2025-01-22 22:58:28 +00:00

Fixed the font issue while saving pdf

Added font support for Basic Template
Added feature to select between platform safe fonts
This commit is contained in:
Piyush Singhania 2021-10-25 21:46:12 +05:30
parent a242979108
commit 91b3d969c2
3 changed files with 25 additions and 11 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];
}
}
@ -250,13 +250,17 @@ 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));
const sleep = m => new Promise(r => setTimeout(r, m));
(async () => {
await sleep(3000);
printWindow.webContents.printToPDF(printOptions).then(data => {
printWindow.close();
fs.writeFile(destination, data, error => {
if (error) throw error;
resolve(shell.openItem(destination));
});
});
});
})();
});
});
}