Reimplement Document#group without transactions #678

Closed
practicingruby opened this Issue Feb 20, 2014 · 11 comments

Projects

None yet

6 participants

@practicingruby
Member

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.

@practicingruby practicingruby added this to the 1.0 Wishlist milestone Feb 24, 2014
@ddengler
ddengler commented Mar 7, 2014

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.

@practicingruby
Member

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.

@ddengler
ddengler commented Mar 9, 2014

@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

@practicingruby
Member

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.

@ollym
ollym commented Mar 24, 2014

Only just found this issue, should of really commented this here:
#675 (comment)

@romand
romand commented Mar 27, 2015

here is what I've got, it handles bounding boxes correctly and works for subclasses of Document
https://gist.github.com/a0a4c07aac98e28ac634
based on @ddengler 's code

@huwd
huwd commented Jul 26, 2016

Hello everyone,

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?

@ddengler

@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.

@huwd
huwd commented Jul 27, 2016

๐Ÿ‘ 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!

@packetmonkey
Contributor

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.

@ddengler
ddengler commented Aug 2, 2016

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment