Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement Document#group without transactions #678

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

Reimplement Document#group without transactions #678

practicingruby opened this issue Feb 20, 2014 · 11 comments

Comments

@practicingruby
Copy link
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
Copy link

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
Copy link
Member Author

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
Copy link

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
Copy link
Member Author

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
Copy link

ollym commented Mar 24, 2014

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

@romand
Copy link

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
Copy link

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
Copy link

@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
Copy link

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
Copy link
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
Copy link

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
Development

No branches or pull requests

6 participants