This probably means creating a limited version of what we have before that uses height calculations rather than transactions to decide what can fit on a page.
I am currently playing around with this a bit. My current strategy is to create a temporary document with the same settings as the original page, render the group and decide what to do in the original based on the result. Anything special I have to look out for? At least for the few scenarios I already tested, it is looking good. Hope I won't hit any major road blocks.
The difficulty I can see in doing that is making sure that you actually restore the insane amount of state Prawn::Document relies on under the hood (many of the mixed in modules introduce state).
Still, I'd be interested in seeing a pull request with your solution, even if it's only for discussion purposes.
@sandal I created a gem with my experimental implementation as we discussed. It is available at https://github.com/ddengler/prawn-grouping or via rubygems prawn-grouping
Thanks @ddengler! I will keep this ticket open for a while to encourage us to come up with a more robust solution, but your gem should be a great workaround for the time being.
Only just found this issue, should of really commented this here:
here is what I've got, it handles bounding boxes correctly and works for subclasses of Document
based on @ddengler 's code
Does anyone have a running workaround for this, @romand the Gist link above is now dead and it looks like it's been a while since anyone spoke about this - is there currently a way to stop paragraphs breaking across a page/column boundary?
@huwd does my grouping gem https://github.com/ddengler/prawn-grouping solve this for you? If not, please let me know in the projects issue tracker. I did not have the time to update the project recently, but if there are fundamental issues with the approach I will look into it again for you.
👍 For future finders of this thread, I can confirm the gem @ddengler wrote works beautifully (2016 edition of 'this works') - used in a Rails 5 app with Prawn 1.0.0. 🎉 Thank you!
This issue was left open to see if there was a better solution for this problem than the prawn-grouping gem. It looks like nobody has come up with one and it's solving real issues so I created a Related Gems wiki page and added it there for people to find it (with some other gems I know about off hand).
@ddengler if there is anything in Prawn we could add to make implementing your gem easier, let us know. Happy to help extend the prawn ecosystem.
@packetmonkey thanks for mentioning the project in the wiki and for the offer to open up prawn to the plugin. I will look into the latest prawn version, update the plugin and let you know if I have any API related issues.