gutschilla / elixir-pdf-generator

Create PDFs with wkhtmltopdf or puppeteer/chromium from Elixir.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ability to create a PDF in chunks to stream it

DaveElGhoul opened this issue · 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

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