Label report fixes & report options are not longer shared
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Joan Sanchez 2020-07-06 08:27:05 +02:00
parent 6fe50dc040
commit c6dc1b6b23
2 changed files with 6 additions and 12 deletions

View File

@ -21,18 +21,13 @@ class Report extends Component {
async toPdfStream() { async toPdfStream() {
const template = await this.render(); const template = await this.render();
let options = Object.assign({}, config.pdf); const defaultOptions = Object.assign({}, config.pdf);
const optionsPath = `${this.path}/options.json`; const optionsPath = `${this.path}/options.json`;
const fullPath = path.resolve(__dirname, optionsPath); const fullPath = path.resolve(__dirname, optionsPath);
let options = defaultOptions;
if (fs.existsSync(fullPath)) if (fs.existsSync(fullPath))
options = Object.assign(options, require(optionsPath)); options = require(optionsPath);
/* return new Promise(resolve => {
pdf.create(template, options).toStream((err, stream) => {
resolve(stream);
});
}); */
const browser = await puppeteer.launch({headless: true}); const browser = await puppeteer.launch({headless: true});
const page = await browser.newPage(); const page = await browser.newPage();
@ -40,7 +35,7 @@ class Report extends Component {
const element = await page.$('#pageFooter'); const element = await page.$('#pageFooter');
let footer = ''; let footer = '\n';
if (element) { if (element) {
footer = await page.evaluate(el => { footer = await page.evaluate(el => {
const html = el.innerHTML; const html = el.innerHTML;
@ -52,7 +47,6 @@ class Report extends Component {
options.headerTemplate = '\n'; options.headerTemplate = '\n';
options.footerTemplate = footer; options.footerTemplate = footer;
console.log(options);
const buffer = await page.pdf(options); const buffer = await page.pdf(options);
await browser.close(); await browser.close();

View File

@ -1,5 +1,4 @@
{ {
"landscape": true,
"width": "10.4cm", "width": "10.4cm",
"height": "4.8cm", "height": "4.8cm",
"margin": { "margin": {
@ -7,5 +6,6 @@
"right": "0cm", "right": "0cm",
"bottom": "0cm", "bottom": "0cm",
"left": "0cm" "left": "0cm"
} },
"printBackground": true
} }