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

PDF Print

This commit is contained in:
Faris Ansari 2018-10-23 02:18:38 +05:30
parent bd3b266a69
commit 935d5a340f
2 changed files with 21 additions and 4 deletions

View File

@ -15,13 +15,13 @@ module.exports = function registerServerMethods() {
frappe.registerMethod({
method: 'print-pdf',
handler({doctype, name}) {
handler({doctype, name, html}) {
if (frappe.isElectron) {
const path = require('path');
const { getPDFForElectron } = require('frappejs/server/pdf');
const { getSettings } = require('../electron/settings');
const destination = path.resolve(getSettings().dbPath, '..')
getPDFForElectron(doctype, name, destination);
getPDFForElectron(doctype, name, destination, html);
}
}
})

View File

@ -1,8 +1,13 @@
<template>
<div class="bg-light">
<page-header :title="doctype" />
<div class="form-container col-8 bg-white mt-4 ml-auto mr-auto border">
<component :is="printComponent" v-if="doc" :doc="doc" />
<div class="row no-gutters">
<div class="col-8 mx-auto text-right mt-4">
<f-button primary @click="makePDF">{{ _('PDF') }}</f-button>
</div>
<div ref="printComponent" class="form-container col-8 bg-white mt-4 mx-auto border">
<component :is="printComponent" v-if="doc" :doc="doc" />
</div>
</div>
</div>
</template>
@ -29,6 +34,18 @@ export default {
async mounted() {
this.doc = await frappe.getDoc(this.doctype, this.name);
this.printComponent = printComponents[this.doctype];
},
methods: {
makePDF() {
frappe.call({
method: 'print-pdf',
args: {
doctype: this.doctype,
name: this.name,
html: this.$refs.printComponent.innerHTML
}
})
}
}
}
</script>