prawnpdf/prawn — pull request #690 by ddengler (2014-03-08 10:58:27+00:00)
Title: Add groups based on temporary documents to fix #678

After your comment on all the state I basically went down the same bumpy road of deep copies and obviously hit the same problems like marshalling of fonts as you guys did, so I took a step back and tried to just recreate a new document again.

From my point of view, in the temporary documents it does not matter if colors etc. are not set properly, as long as everything that affects flow and scale is set, because we throw it away and render in the original document. I might have missed something here, but for my tested scenarios it worked perfectly.

It also allows nested grouping (performance?). I removed the Error (not being able to group) and added three callbacks so the user can decide what to do before the three possible grouping events. For example create a new page even if the grouped contend exceeds one page.

Let me know what you think and I can add a few more tests and clean this up a bit.