-
Notifications
You must be signed in to change notification settings - Fork 101
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
Word wrap in cell #67
Comments
The question is, what would you expect? The two latter not to be wrapped at all, or to be wrapped typographically correctly? As far as I know, Prawn::PDF tries to calculate the reasonable width for a column. This may not always work out as expected. The main problem is, that the first cell could use all the width, so there is only reserved a minimum width for the other cells. The first possibility: cells << "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages"
cells << { content: "Word", width: 50 }
cells << { content: "Longword", width: 80 } The second possibility: cells << "..."
cells << "Wo#{Prawn::Text::SHY}rd"
cells << "Long#{Prawn::Text::SHY}word" |
Thank you for suggestions, I will try the second option. The first is problematic with variable text inputs. To your question, I would expect the same behaviour as browsers do with HTML tables (https://jsfiddle.net/mjhpbequ/), so wrap only by white spaces and never wrap a single word. |
You could calculate the needed width for the columns by finding the longest word for that column. If the longest word fits, Prawn will probably not wrap single characters but only break with spaces (like in the first column). pdf.width_of(longest_word, size: 12) # + small margin probably |
PR #68 may help here by allowing you to set a Going forward, I could see a text cell option for |
My opinion of what should be done is to first sizing should be tried that avoids splits on non-empty spaces any words (like #98). If this fails, then existing heuristics would be fine. Having ability to set manually Just FYI presently one can end up with a field that is overly long while wrapping words in another. This can be replicated with data like: LONG_ADDRESS = [%w[Name Farnsworth],
['Address', %{JOHN "GULLIBLE" DOE\nCENTER FOR FINANCIAL ASSISTANCE TO DEPOSED NIGERIAN ROYALTY\n421 E DRACHMAN
TUCSON AZ 85705-7598}],
%w[Country Patagonia]].freeze
@pdf.table(LONG_ADDRESS, width: 90.mm) |
Hello,
I saw few issues existing about cell sizing and wrapping but quite old so sorry if I'm creating any duplicate, but I can't figure how to disable word wrap by character in cell and I'm not sure whether it is bug or my lack of knowledge as I'm trying prawn-table first day.
Output: https://timi.cz/system/example.pdf - I would expect words in the last two cells not to be wrapped by character.
Using the latest from master branch:
and
Thanks for help.
The text was updated successfully, but these errors were encountered: