From c6dc1b6b23d9fdc893e3fa094614bbd7fe8d94c4 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Mon, 6 Jul 2020 08:27:05 +0200 Subject: [PATCH] Label report fixes & report options are not longer shared --- print/core/report.js | 14 ++++---------- print/templates/reports/item-label/options.json | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/print/core/report.js b/print/core/report.js index dd305cc89..ea6a360b5 100644 --- a/print/core/report.js +++ b/print/core/report.js @@ -21,18 +21,13 @@ class Report extends Component { async toPdfStream() { const template = await this.render(); - let options = Object.assign({}, config.pdf); + const defaultOptions = Object.assign({}, config.pdf); const optionsPath = `${this.path}/options.json`; const fullPath = path.resolve(__dirname, optionsPath); + let options = defaultOptions; if (fs.existsSync(fullPath)) - options = Object.assign(options, require(optionsPath)); - - /* return new Promise(resolve => { - pdf.create(template, options).toStream((err, stream) => { - resolve(stream); - }); - }); */ + options = require(optionsPath); const browser = await puppeteer.launch({headless: true}); const page = await browser.newPage(); @@ -40,7 +35,7 @@ class Report extends Component { const element = await page.$('#pageFooter'); - let footer = ''; + let footer = '\n'; if (element) { footer = await page.evaluate(el => { const html = el.innerHTML; @@ -52,7 +47,6 @@ class Report extends Component { options.headerTemplate = '\n'; options.footerTemplate = footer; - console.log(options); const buffer = await page.pdf(options); await browser.close(); diff --git a/print/templates/reports/item-label/options.json b/print/templates/reports/item-label/options.json index 1cc4e1529..98c5788b1 100644 --- a/print/templates/reports/item-label/options.json +++ b/print/templates/reports/item-label/options.json @@ -1,5 +1,4 @@ { - "landscape": true, "width": "10.4cm", "height": "4.8cm", "margin": { @@ -7,5 +6,6 @@ "right": "0cm", "bottom": "0cm", "left": "0cm" - } + }, + "printBackground": true } \ No newline at end of file