ddengler / prawn-grouping

A gem to add a more flexible grouping option to the prawn gem
https://github.com/ddengler/prawn-grouping
MIT License
14 stars 21 forks source link

Failure pushing content to the next column #10

Open giuseb opened 9 years ago

giuseb commented 9 years ago

I have multiple-choice test sheets with two columns, and I want the entire Q&As item to stick together. In some cases, however, the content gets split across columns.

This spec replicates the behavior, which I did NOT encounter using Prawn 1.0.0.rc2 (just prior to when grouping was disabled).

(please note that the spec simply writes the PDF file; sorry, I don't know how to formulate proper expectations in this context)

ddengler commented 9 years ago

I will look into it.

A general note: This plugin is not an extraction from prawn. It is a totally different approach to what prawn did. Prawn tried to implement transactions for grouping, which resulted in uncontrollable deep copy issues and got the feature disabled in the end. This plugin attempts to simulate the grouping block in a new document (replicating the basic document structure) and then executes the "best" match in the original document.

giuseb commented 9 years ago

Got it, thank you. Please let me know if there is something else I can do to help. I looked at the source and could not spot an obvious explanation right away.

ddengler commented 9 years ago

Just want to let you know, that I have not forgotten about this. Found the underlying issue, but no acceptable solution at this point.

giuseb commented 9 years ago

Thanks. Any chance you could briefly point out the issue? Is it the columns? Just wondering if it's something I might take a stab at myself...

ddengler commented 9 years ago

Yes, the columns do not get reflected in the virtual copy. The grouping worked in some test cases but not in others, because a full width text is obviously only about the length of the same text within columns. My current approach is simply to replicate the columns, but I have not found a clean solution yet.

giuseb commented 9 years ago

Hi again, I may have worked out a solution to this issue. The idea is to manipulate the way the virtual document is initialized, by removing left and right margins and setting its width to that of the current bounding_box. I have created a feature branch, please let me know if it looks reasonable to you. I should probably add a few more specs, by the way. Cheers, Giuseppe

ddengler commented 9 years ago

I get the idea and see why this works for your column problem, but I have a bad feeling about what this might do to more complex groups. I will do some tests (I will try to break it) and consider a beta release if this is the only solution we can come up with to solve this.