Skip to content

Commit 676014a

Browse files
authored
Fix puppeteer script STDOUT issue
see #16
1 parent 43e2278 commit 676014a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Resources/docs/provider/puppeteer.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,23 @@ const format = args[2];
2828

2929
await page.goto('data:text/html,' + html, { waitUntil: 'networkidle0' });
3030

31+
let buff = null;
32+
3133
if (format == 'pdf') {
32-
await page.pdf({
33-
path: 1, // STDOUT_FILENO
34+
buff = await page.pdf({
3435
format: 'A4',
3536
printBackground: true,
3637
margin: { top: '1cm', right: '1cm', bottom: '1cm', left: '1cm' }
3738
});
3839
} else {
39-
await page.screenshot({
40-
path: 1, // STDOUT_FILENO
40+
buff = await page.screenshot({
4141
type: format,
4242
quality: 100,
4343
});
4444
}
4545

46+
process.stdout.write(buff);
47+
4648
await browser.close();
4749
})();
4850
```

0 commit comments

Comments
 (0)