I am using wkhtmltopdf + wicked_pdf to generate pdf. I am using sidekiq to background it. Following is my configuration

pdf = render_to_string :pdf => pdf_request.file_name,
       :layout => "pdf.html",
       :template => "shared/report",
       :formats => [:pdf],
       :margin => {:top => 10, :bottom => 0},
       :disable_javascript => true

Once the html file is generated in the tmp folder, I see a sudden increase in memory.

For eg, I watched memory utilization while generating a pdf with 200k records(~3000 pages). Memory started to increase around 20MB per second after the html file was generated in the tmp files. I guess its the time when it actually writes to the pdf file. I keeps increasing and the process fails running out of memory.

My pdf has a table on each page with 70 rows.

Has any one else seen this behaviour? Is there anything I could do to reduce memory consumption?

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top