Search code examples
pdf-generationpuppeteer

Creating PDF files with Puppeteer generates files too large


We used to generate PDF files with phantom and now switching to puppeteer. The files we would generate (~50 files) would come out 40-50 KB in size.

Now that we use puppeteer the same files (using the same data, same image for the logo, etc) are generated and range 190-2125 KB in size.

We've tried looking through the npm docs for the package description, or some setting that we can change, but found nothing.

Ideas welcome.


Solution

  • As Puppeteer uses chromium to generate pdf files and according to this article this is a known problem. (scroll to the end.. issue still open) .

    You coudl try to "optimize" your jpeg files using imagemin-jpegoptim module or to completetly use some other file type.

    What about creating a screenshot as image instead of pdf?