Forum Feature requests

How to force long text/URLs to wrap

I have a document in which long URLs are carrying on past the margins. Prince-linebreak-magic (auto) is not helping, because the URLs have long stretches without slashes. The following CSS methods, though they fix the problem in the browser, seem to have no effect on Prince's PDF output.
	white-space: pre;           /* CSS 2.0 */
	white-space: pre-wrap;      /* CSS 2.1 */
	white-space: pre-line;      /* CSS 3.0 */
	white-space: -pre-wrap;     /* Opera 4-6 */
	white-space: -o-pre-wrap;   /* Opera 7 */
	white-space: -moz-pre-wrap; /* Mozilla */
	white-space: -hp-pre-wrap;  /* HP Printers */
	word-wrap: break-word;      /* IE 5+ */

Furthermore, this trick from another post in this forum ( isn't having any effect:
.myselector a {
    prince-text-replace: '.' '.\200B';
    prince-text-replace: '-' '-\200B'; /* I also tried this */

Manually inserting the code for a zero-width space (​) did work, but it's obviously not ideal. Is there a way to achieve this wrapping that I am overlooking? Is there something I am missing in Prince's handling of the white-space or word-wrap property? Is there a favored javascript method of achieving this?

An example of a URL that's not obeying margins is
Breaking after ampersands might help for this example:
.myselector a {
    prince-text-replace: '&' '&\200B';
Note that if you want multiple replacements, you need to combine them in one property, like this:
.myselector a {
    prince-text-replace: '&' '&\200B' '-' '-\200B'
I had hoped that "prince-linebreak-magic: auto;" would have dealt with this but unless I'm using it wrong, it doesn't. In the future I'd like to see this tag force this.

Anyway, breaking after ampersands does not fix this issue in all conditions. In my work, I also wrote a preprocessor that manually inserts zero-width spaces into links, every 16 characters. This seems to work perfectly and is easy to do, but I agree with the OP should be automatic.
This can be done with JavaScript in Prince 8.0, although it is questionable whether printing very long URLs has any value. If the PDF files will not be printed, then the URLs can be left as regular links, viewable on mouse over.
Prince 10 now supports "word-wrap: break-word", which is ideal for breaking long URLs.
@mikeday - I have a similar problem.

I have a pretty long URL ( inside a div which is absolute positioned.
The URL does break on "-" but its broken (It is not clickable). And if you copy and paste in the address bar then it misses the "-" which gives us 404 error. So, I have to manually put "-" in the URL to make it work.

I tried replacing "-" with "%2D" and the URL works fine but it does not break into next line. It overflows out of the div box.

I am using Prince version 8.

Any suggestions how can I achieve wrapping with clickable URL?
Also, if the subdomain itself is very long and does have "-billing" (

It does not wrap the URL. It overflows outside the div.
Prince 10 has improved URL support and the "word-wrap: break-word" property, which should do what you need.