-
Notifications
You must be signed in to change notification settings - Fork 2k
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
How to wrap the text inside the table cell #204
Comments
Is this a duplicate of #203 ? |
Its not same as #203, the issue is as shown below The content in the "Data Type" column is getting overlapped into the next column "Length". |
Ok, could you provide us with a (minimal) document definition to reproduced the problem? |
below is the document definition for the table.
|
Ah, I see. The cell is to small for the word. pdfmake never breaks words, it only breaks when you have a whitespace or punctation. If you change the line ['','aabcdefghijklmno', ''], to ['','aabcdef ghijklmno', ''], it works. This behaviour is not specific to tables. I'll tag it as feature request, but don't hope for a fast solution - breaking words is language dependant. |
Thank you for the clarification. |
@jthoenes: breaking words is language dependent if done well (i.e. put a hyphen in somewhere that breaks on the end of a syllable). But breaking words badly would probably be OK here - since the problem only happens when a cell is too narrow to fit the whole word, it's likely that people would be happy with you just arbitrarily chopping at the cell width. Is that possible? In fact, for my use case I'd even be happy with an ellipses on the end or a truncate. It just looks very unfinished for it to fall out of the cell. |
@PaulL1 There is no easy fix for this, because words are calculated before they are fitted onto the lines. That could of course be improved. Have a look in https://github.com/bpampuch/pdfmake/blob/master/src/textTools.js if you want to have a look yourself. |
Ok, so I think what you're saying is that splitWords basically breaks all the text down into individual words, and puts them in a big array. But I don't see where the code is that writes an individual cell in the table and decides when to put a newline in. I don't think that's included in splitWords, because it never calls sizeOfString, and appears to have no knowledge of the column width it's writing in. Leaving aside that I can't find the code, it seems that the logic would be to take the wordArray and write them one by one into a line until writing another would be wider than the available space. Then it should start a new line, and start writing words. If that's the basic logic, then presumably it also has an exception rule that it must write at least one word (even if that word falls outside the available space). So when that exception is triggered then the change would be to instead have a go at breaking the word into two shorter strings, and only putting the first part on the current line. Is that logic in the code somewhere? If I can navigate the code base I'm happy to have a go at it. |
Hi, have a look at |
OK, so it looks like the logic is that we call In When building a line it calls I can see the outlines of a solution. I would modify
I would then modify
Finally, we need a new My stab at that doesn't measure properly, but is:
It doesn't work, which doesn't help much. I'm ending up with a couple of largely blank pages, and no errors anywhere in the javascript console. My first guess would be that the code doesn't like my butchering of the inlines to clone one. Perhaps someone who knows the pdfMake internals better could use this as inspiration to do something? |
Thanks for the analysis. The cloning is probably the issue - because pdfmake keeps references at some places. |
Can you add " _ " (underscore) also as a valid delimiter for long text. Looks like the cell content does not wrap even when the text has underscores in them. |
Yes I am also facing same issue.. |
We recently came across this problem and found a workaround that works in some cases. I'll just leave this here as an input if someone experiences the same. Here's a content which is too big for its cell: As a workaround we added a row and used _Note: This does not solve the problem, but may work in some cases with the right content._ |
Hi @jthoenes Any update about this feature ? Thanks. |
+1 for adding '_' to the list of delimiting / breakable characters |
+1 as well for the '_' wrapping! |
+1 for adding '_' to wrap text |
I am also having the same issue since I am exporting a UI Grid. Has this been resolved? "Yes I am also facing same issue.. |
@jthoenes Could you add the zero-width space to the list of breaking characters? This way, I could tell pdfmake where to break my words by adding an invisible zero-width space ( |
@jostang Unicode character "ZERO WIDTH SPACE" is breaking character in version 0.1.23 and above. |
@liborm85 Great, thank you! I was still using 0.1.20 |
Support for wrapping non-wrappable long words implemented by commit: 4c5599d |
New version pdfmake released. |
Has this broken the newline (\n) processing, I just can't get it to recognise newline characters in a table cell, tough all the examples say it should work? |
Did you try it out in the playground?
…On Tue, 6 Jun 2017 at 16:11, aa-telali ***@***.***> wrote:
Has this broken the newline (\n) processing, I just can't get it to
recognise newline characters in a table cell, tough all the examples say it
should work.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#204 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKQm54J_CKHB9n3fy3D8B1O5jDg97iWtks5sBV4ogaJpZM4Dha1->
.
|
I am having the same issue with words not wrapping when setting all table widths to "auto". I have dynamic tables passed from an UI and therefore I do this: It is no problem when I give a fixed width for each column like this: But I want the "auto" so that I get the maximum space for each column if needed. With the fixed width words do wrap like they should but I sometimes have unwanted white space and therefore wasted space for other columns. Does anyone know a fix? |
@jthoenes could we modify https://github.com/bpampuch/pdfmake/blob/master/src/textTools.js to work with |
Sorry for bumping a dead issue, but I'm still getting this problem when using large filenames in a table, for example: I am using pdfmake 0.1.71. |
I'm bumping this issue, I have a long string that i can't break manually (think JWT or similar in length) and i need to render this in a table so i can provide a background color and some padding (well the illusion of padding). Any help greatly apreciated. |
For whom is still interested I found a quick workaround: |
Hello,
When the cell content exceeds the column width, it is either getting truncated or the remaining content is overlapping into the next cell, How do we wrap the cell content
The text was updated successfully, but these errors were encountered: