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

[PDF] remove electron specific PDF code

This commit is contained in:
Prateeksha Singh 2018-07-16 19:42:00 +05:30
parent 5704a2f170
commit 1e70c56d1c
3 changed files with 6 additions and 32 deletions

View File

@ -23,7 +23,6 @@
"express": "^4.16.2",
"flatpickr": "^4.3.2",
"frappe-datatable": "^1.1.2",
"fs": "^0.0.1-security",
"jquery": "^3.3.1",
"jwt-simple": "^0.5.1",
"luxon": "^1.0.0",
@ -37,7 +36,6 @@
"nodemon": "^1.14.7",
"nunjucks": "^3.1.0",
"octicons": "^7.2.0",
"os": "^0.1.1",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"popper.js": "^1.12.9",

View File

@ -5,7 +5,9 @@
<f-button primary v-if="showSave" :disabled="disableSave" @click="$emit('save')">{{ _('Save') }}</f-button>
<f-button primary v-if="showSubmit" @click="$emit('submit')">{{ _('Submit') }}</f-button>
<f-button secondary v-if="showRevert" @click="$emit('revert')">{{ _('Revert') }}</f-button>
<f-button secondary v-if="showNextAction" @click="$emit('print')">{{ _('Print') }}</f-button>
<div class="ml-2">
<f-button secondary v-if="showNextAction" @click="$emit('print')">{{ _('Print') }}</f-button>
</div>
<dropdown class="ml-2" v-if="showNextAction" :label="_('Actions')" :options="links"></dropdown>
</div>
</div>
@ -51,6 +53,8 @@ export default {
&& !this.doc._notInserted
&& this.doc.submitted === 1;
this.showNextAction = 1
this.showNextAction =
!this.doc._notInserted
&& this.links.length;

View File

@ -15,10 +15,6 @@
import { getHTML } from '../../../common/print.js';
import PrintActions from './PrintActions';
// for PDF in Electron
import { BrowserWindow, remote, ipcMain, ipcRenderer, shell } from 'electron'
import fs from 'fs';
export default {
name: 'PrintView',
props: ['doctype', 'name'],
@ -39,31 +35,7 @@ export default {
},
getPDF() {
// Open a hidden window
let printWindow = new remote.BrowserWindow(
// { show: false }
);
printWindow.loadURL(
"data:text/html;charset=utf-8," + encodeURI(this.printTemplate)
);
printWindow.on("closed", () => {
printWindow = null;
});
// const pdfPath = path.join(os.tmpdir(), 'print.pdf')
const pdfPath = '/Users/prateekshasingh/Desktop/print.pdf';
// Use default printing options
printWindow.webContents.printToPDF({}, (error, data) => {
if (error) throw error;
// printWindow.close();
fs.writeFile(pdfPath, data, (error) => {
if (error) throw error;
shell.openExternal(`file://${pdfPath}`);
})
});
frappe.getPDF(this.doctype, this.name);
}
}
}