Support .omitBackground as option to .pdf()
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: m85 (remote) / m90 7.1.0 (local)
- Platform / OS version: browserless.io (remote) / Windows 10 x64 (local)
- Node.js version: 14.15.1 (local) and 15.9.0 (local)
What steps will reproduce the problem?
.pdf() cannot generate a transparent output to be used as watermark.
I have uploaded a .zip containing all tests with a valid output and an invalid output (via puppeteer).
My suggestion is allow omitBackground property (like .screenshot()) with the .pdf() method. So outputs could be used as watermark.
It was discussed here: https://github.com/puppeteer/puppeteer/issues/2545 and a workaround here https://github.com/puppeteer/puppeteer/issues/2545#issuecomment-397590569. It works, but is a hacky way and could stop works at anytime. So a definitive solution is better via options.
What is the expected result?
Generated PDF output be optionally transparent.
What happens instead?
PDF have a opaque background.
Test
- Run
npm i puppeteer - Download pdfbox to use
OverlayPDFtool. - Following example doc, run
node example.jsto generate a PDF via puppeteer. You could setbackground-color: transparent, but it will not help. - Run
java -jar pdfbox.jar OverlayPDF puppeteer-output.pdf original.pdf output.pdf(original.pdfis just any PDF document to be overlayed, the “original document” to be watermarked with the puppeteer PDF output)
The zip attached contains all files to test.
Expected output:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (1 by maintainers)

Top Related StackOverflow Question
I’ve added this functionality in the PR above (forgot to update this issue before). It’s included in v9.0.0.
Woohoo!!!