elixir-pdf-generator icon indicating copy to clipboard operation
elixir-pdf-generator copied to clipboard

Ability to create a PDF in chunks to stream it

Open DaveElGhoul opened this issue 2 years ago • 1 comments

Currently, PdfGenerator accepts only 1 HTML content and creates a file from it.

I would like to suggest an update to the library, where we have the ability to create a pdf file in chunks, to not have to wait to receive the full content to then render an html template, to then create a pdf file then at this stage start downloading the Pdf.

Therefore, the ability to use send_chunked(conn, 200) and chunk the pdf file

DaveElGhoul avatar Mar 29 '22 15:03 DaveElGhoul

Thanks for the interring idea. Right now this would require a bit of research as behind the scenes (at least using WKHTMLTOPDF, no idea about Chrome/Puppeteer at the moment) this library waits for the underlying PDF generator to finish processing and then reads the whole result (the PDF file) in one go. Of course one could read that in chunks or use File.steam if that would be of any help.

More interesting would be that we stream by every generated page .. but how to convince WKHTMLTOPDF to do indicate every single page as binary .. hmmm

gutschilla avatar Jun 28 '22 21:06 gutschilla