From 935d5a340fec5a8c00ecd5bf9bea28c8e67078c2 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 23 Oct 2018 02:18:38 +0530 Subject: [PATCH] PDF Print --- server/registerServerMethods.js | 4 ++-- src/pages/PrintView/index.vue | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/server/registerServerMethods.js b/server/registerServerMethods.js index 0e18e922..b27fbdf6 100644 --- a/server/registerServerMethods.js +++ b/server/registerServerMethods.js @@ -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); } } }) diff --git a/src/pages/PrintView/index.vue b/src/pages/PrintView/index.vue index 2db239f2..ab071eef 100644 --- a/src/pages/PrintView/index.vue +++ b/src/pages/PrintView/index.vue @@ -1,8 +1,13 @@ @@ -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 + } + }) + } } }