rkusa / pdfjs

A Portable Document Format (PDF) generation library targeting both the server- and client-side.
MIT License
774 stars 142 forks source link

Can I create a large pdf without loading the entire file into memory? #306

Closed justinmchase closed 1 year ago

justinmchase commented 1 year ago

Suppose I have 100 images, and I want to create a single PDF with each of these images as a single page. I want to use a streaming api where I am streaming each file 1 at a time and piping it into the pdf which then writes to disk.

I have a memory constrained system and if it attempts to load the entire pdf into memory on this system it could crash. Is it possible to achieve this with the streaming api?

rkusa commented 1 year ago

Not right now I am afraid. pdfjs is/was meant for such use-cases, but this isn't working correctly for images right now (https://github.com/rkusa/pdfjs/issues/291#issuecomment-1378754340). So I cannot recommend pdfjs for your use-case until this is fixed.