Label report fixes & report options are not longer shared
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
6fe50dc040
commit
c6dc1b6b23
|
@ -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();
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue