question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support .omitBackground as option to .pdf()

See original GitHub issue

Steps 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

  1. Run npm i puppeteer
  2. Download pdfbox to use OverlayPDF tool.
  3. Following example doc, run node example.js to generate a PDF via puppeteer. You could set background-color: transparent, but it will not help.
  4. Run java -jar pdfbox.jar OverlayPDF puppeteer-output.pdf original.pdf output.pdf (original.pdf is 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:

output-valid puppeteer-test.zip

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
d-rowecommented, Sep 19, 2021

I’ve added this functionality in the PR above (forgot to update this issue before). It’s included in v9.0.0.

1reaction
gavin310commented, Sep 19, 2021

I’ve added this functionality in the PR above (forgot to update this issue before). It’s included in v9.0.0.

Woohoo!!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add backgrounds to PDFs, Adobe Acrobat
Open the PDF file to which you want to add the background. · Choose Tools > Edit PDF. · In the secondary toolbar,...
Read more >
Save or convert to PDF or XPS in Office Desktop apps
You can use the Office programs to save or convert your files to PDFs so that you can share them or print them...
Read more >
Puppeteer: omitBackground does not work with header or ...
The code works fine and give me the perfect transparent PDF using omitBackground:true . But when I use headerTemplate or footerTemplate I ...
Read more >
What does PDF mean and how do I save a file as a PDF?
pdf ) - If you don't see this as an option in the menu, make sure you have the free Adobe Reader software...
Read more >
Signature with transparent background | Adobe Acrobat
TIF & GIF do have an option for Transparency, as long as it's enabled, but ultimately you need to convert the file to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found