mirror of
https://github.com/frappe/books.git
synced 2024-11-09 23:30:56 +00:00
Merge pull request #13 from piyushsinghania/fix/wrong-font-in-saved-pdf
Fixed the font issue while saving pdf
This commit is contained in:
commit
ca0c2968e0
@ -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',
|
||||
|
@ -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">
|
||||
|
29
src/utils.js
29
src/utils.js
@ -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));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user