-
Hello @gettalong 😊 I was playing around with the plugin. I have a use case where a PDF for the entire year needs to be generated which contains every employee and data about their payslips. Is there a way to progressively write in a StringIO or TempFile and, after writing, resetting the Composer (keeping styles but forgetting pages) ? And afterwards to concatenate the new pages to the Tempfile ? I tried to merge, but the issue is that it still loads all the objects using that method.. 😅 Did I miss something ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 13 replies
-
Hello @loust333, It is currently not possible to do that kind of streaming because creating the pages is separate from writing the PDF. However, it might be possible to save some memory by finalizing pages earlier. I will have to look at this to see how this could be done (similar to how forgetting the Do you have some generalized example code for your use-case that you can share? |
Beta Was this translation helpful? Give feedback.
I just added the needed require statements and changed
#present?
and#second
to their plain Ruby counterparts. That made the script run-able without Rails, giving your results. Then I commented out theBenchmark.measure
lines (56/57 plus their respectiveend
lines).I haven't looked at 'benchmark-memory' but in my experience all memory measurement tools have some overhead, especially when many objects are involved as in this case. The difference in memory usage on the medium difficulty level was ~200MiB without Benchmark.memory and ~1400MiB with it.