diff --git a/src/converter.ts b/src/converter.ts index 32a90330..78d2bfeb 100644 --- a/src/converter.ts +++ b/src/converter.ts @@ -392,6 +392,13 @@ export class Converter { await render() await page.emulateMediaType('print') + if (opts.type === ConvertType.png) { + // Enable transparency + await page.addStyleTag({ + content: ':root,body { background:transparent !important; }', + }) + } + const screenshot = async (pageNumber = 1) => { const clip = { x: 0, @@ -406,7 +413,11 @@ export class Converter { type: 'jpeg', }) - return await page.screenshot({ clip, type: 'png' }) + return await page.screenshot({ + clip, + omitBackground: true, + type: 'png', + }) } if (opts.pages) {