diff --git a/print/templates/reports/delivery-note/delivery-note.js b/print/templates/reports/delivery-note/delivery-note.js index 22b0a7cf68..5bf9824f69 100755 --- a/print/templates/reports/delivery-note/delivery-note.js +++ b/print/templates/reports/delivery-note/delivery-note.js @@ -3,6 +3,7 @@ const Component = require(`${appPath}/core/component`); const reportHeader = new Component('report-header'); const reportFooter = new Component('report-footer'); const md5 = require('md5'); +const fs = require('fs-extra'); module.exports = { name: 'delivery-note', @@ -24,11 +25,14 @@ module.exports = { }, computed: { dmsPath() { - const pathHash = md5(this.signature.id.toString()).substring(0, 3); - const hostPath = `file:///${config.storage.root}/${pathHash}`; + if (!this.signature) return; - if (this.signature && this.signature.id) - return `${hostPath}/${this.signature.id}.png`; + const hash = md5(this.signature.id.toString()).substring(0, 3); + const file = `${config.storage.root}/${hash}/${this.signature.id}.png`; + const src = fs.readFileSync(file); + const base64 = Buffer.from(src, 'utf8').toString('base64'); + + return `data:image/png;base64, ${base64}`; }, serviceTotal() { let total = 0.00;