Forum Feature requests

Support for CSS3 "word-wrap"

I was curious if there are any plans to include support for the CSS3 declaration "word-wrap" in a future release of PrinceXML? I was able to find a few threads regarding this (Topic #1073 and #941) but the last responses were in 2007. Has there been any consideration since then?

We're currently using Prince to generate dynamic cover pages for our articles and occasionally some of our metadata includes long unbroken URLs (usually in citations) that would potentially overflow floated parent elements without this declaration. This would be a very valuable addition for us and offer greater layout flexibility.

In any case, thanks for your time. I look forward to the response.
We've added behaviour where Prince will break after slashes, which should help with long URLs. Do you want to break at some other point in URLs as well?
Hi Mike,

Thanks for your response. Breaking at the slashes is a great addition and definitely helps out. Breaking at the dot characters within a URL would be very useful as well until word-wrap is supported (which simply breaks at an arbitrary point).

The situation we've come across is that in one of our proposed designs we tried to use a two-inch column on the left side of the page to hold various piece of article metadata. The citation was placed here originally and cited the URL of the paper's HTML abstract page. With the combination of the font-size and a site domain greater than about 30 characters (before the initial slash) we ended up with the overflow problem.
You can do this by inserting zero-width space characters after each dot in the URL. The zero-width spaces act as invisible line break opportunities, allowing the long URL to be split to fit in the available space. Since it can be inconvenient to modify the source document, this can be done using a CSS property:
span.url {
    prince-text-replace: '.' '.\200B'

This rule will replace every dot with a dot followed by a zero-width space (Unicode character U+200B).
That's fantastic Mike, I had no idea this feature was available. Thank you!
While the ability to break long URLs is nice, the CSS3 word-wrap property will break any long string regardless of whether there are slashes or 'dots' in the string. I currently have a layout using word-break to simply avoid breaking the layout in all cases, but this HTML/CSS is ultimately sent to PrinceXml which does NOT support the word-break property and therefore is not an accurate representation of what the user sees on the screen. (And potentially breaks my layout.)

The only option I see at this point is to remove the word-wrap property from my markup and use overflow:hidden instead. Which of course is less desirable as the content will be truncated.

So, I'm also curious to know if/when PrinceXml will support the word-wrap property.

We will need to check the status of this property in the CSS3 Text working draft, and then add it to the development roadmap.
Hi, this feature of Prince where it will break a line after a slash ( / ) is causing us a headache. Prince is splitting our units like ng/(Pa·s·m²) or m²·K/W. We use these a lot in narrow table columns so they split lines a lot.

I have been adding spans with a white-space:nowrap style, but that's turning out to be a lot of work and error-prone.

I tried using the prince-text-replace and the word-joiner char (U+2060), but our fonts don't have that glyph, and I see in that it might not work correctly right now.
I also tried using the prince-text-replace and the zero-width nobreak space char (U+ffef), but our fonts don't have that glyph, either.

I also tried the other slash lookalike characters like 'DIVISION SLASH' (U+2215) and 'FRACTION SLASH' (U+2044), but they don't look like plain slashes, and they also break lines.

Is it possible to have a custom prince- property to override the addition of / as a splittable character? For our purposes, I would probably also use this to add other characters like the dash, so it might be nice to be able to specify a set of characters.

Or is there some other combination of word-wrap settings that would only fix this type of wrapping?
You can use "prince-line-break-magic: none" to disable breaks at slashes.
Thanks, that property is exactly what I needed. I don't know why I didn't find it in my searches, but maybe this thread will help someone else in the future.

Are there any plans to include word-wrap in future versions of Prince?
Yes, when we have time. For now there are some workarounds, like using JavaScript regular expressions to add zero-width spaces between every character. Not as pretty, but it would work.
Cool, thanks for the tip.
What is the status on including the word-wrap support?

No action on this yet, too many other things to do. :(
I have tables that can be up to 80 pages long with about half the columns that have values that can both exceed the column width and do not have white space or other 'nice' characters upon which I can break
the strings. I'm worried that using the proposed work-around (zero-width space character insertion) is going to make a mess of files that later will be edited within Acrobat. These files will be needlessly
larger too. (Adding two bytes for every one-byte glyphs.)

Can you update me on the status of word-wrap support?
The zero-width space characters should not actually be embedded inside the PDF file, Prince will only use them internally to decide where to break lines.
Prince 10 is now available, and finally includes support for the word-wrap / overflow-wrap property. Thank you for your patience, everyone! :D