Actually prince-linebreak-magic is "auto" by default, but currently it only breaks at slashes, not at @ characters. We are just adding support for "word-wrap: break-word" which will allow breaking at any point, this will be available shortly. In the meantime, you could use prince-text-replace to add a zero-width space after the @:
Perfect workaround. Can "prince-text-replace" be used twice? It seem to break my code. I was hoping to also apply the same break point for the dot. Any ideas?
BTW, you guys are the best! Really really really happy with prince. Coming from TCPDF, your system has saved me hours. The amount of work arounds I had to put in place to make TCPDF was ridiculous.
You can apply multiple text replacements like this:
prince-text-replace: 'a' 'b' 'c' 'd'
This will replace 'a' with 'b' and 'c' with 'd'. As with all CSS properties, if you repeat the property multiple times then only the last one will be applied (or the one with the most specific selector).
Hi, what if there is no special character to replace? for example, theemailaddresisveryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyylong@gmail.com I used {price-text-replace: '@', '\200B@'}, but the characters before the "@" sign are still too long to exceed the margin of the table.
The latest Prince alpha version supports "word-wrap: break-word" which will allow breaking anywhere within a word if absolutely necessary to avoid overflow.
I actually need "word-break: break-all" to work. Does the alpha version support "word-break: break-all"? Because my characters are like emails/urls which don't have space between it.
But now I have a real problem, though it's not a bug in Prince. It's just that it doesn't support `line-break` and have some oddly encoded base64 content that's using hyphens, which I would like to not break at.
line-break: anywhere
Is the only (browser) solution I can find.
Unless I can replace the hyphens with a similar looking unicode symbol, but I'm not sure which ones it would break at.
The word-break property only wants to break within a word, so it will not insert break points before trailing punctuation or after leading punctuation (or in Prince, around any punctuation at all).
I think for the general case of wanting to allow breaks between any pair of characters it might be necessary to insert zero-width space characters using JavaScript (or the prince-text-replace property if you only need to add them around specific characters).
Unfortunately the issue is not that extra breaking needs to be inserted, it's that break is happening prematurely (if I understand your explanation correctly) to avoid have to break on a non-word character. This is probably why line-break: anywhere was my first go-to when doing browser testing.
Looking at the test sample again, I can see it in a different light. It's avoiding (as you say) having punctuation at the start or end of a line.
Even Chrome will do that:
Unless
linbreak: anywhere
is set, which I assume is just a big switch to turn all the line wrapping logic off and just dumbly break only when required.
You must admit the humour though -- so much effort just to emulate the behaviour of what would naturally happen when printing a text file on a line printer in 1991.
Anyway, with that in mind, you could give me a precise definition of what prince defines as punctuation? Or just paste the relevant C code right into a message so I can get the output picture-perfect
Currently anything that's not alphanumeric or a mark character, it's quite conservative. If you're dealing with ASCII text then you could just insert a zero-width space after each character.
Though the hyphen is still causing issues, probably because it's just a "break here" kind of character. Still fooling around with CSS options.
Seems there might be a limit (2 or 3?) on how many prince-text-replace can be used at once, with the final ones taking precedence over the earlier ones?
You can apply multiple text replacements like this:
prince-text-replace: 'a' 'b' 'c' 'd'
This will replace 'a' with 'b' and 'c' with 'd'. As with all CSS properties, if you repeat the property multiple times then only the last one will be applied (or the one with the most specific selector).