Forum How do I...?

Word Wrap

sahanap@hotmail.com
I was trying to wrap words which will be displayed in table cell.
For that I had a string builder which will add breaks where ever I need to wrap. When I used <br/>, instaed of wrapping text it displayed <br/> in the field. I tried Environment.Newline. Here in view souce it was wrapping but when I displayed page with brower it was not wrapping. I tried displaying in multiline textbox no luck. I tried ASCII value instead of <br> no luck.

I tried <Pre> tag but when I use this tag I am loosing fonts. I can change font color but not able to change font.

Any idea what is going on here. Any suggestion on how to set font name for PRE tags any other way than <Pre> tags.
mikeday
The <br> issue sounds as if the text is getting escaped as you add it, so that when you add "<br>" to the string it is adding "&lt;br/&gt;" or something like that. But you haven't specified what environment or API or libraries you are using to build up the HTML, so I'm afraid that it is not really possible to answer your question! :)
nishantvarma
Is Word Wrap working in Prince 9 ? We are using Prince 8.x .

We have "Elements" in our HTML that gets replaced elsewhere with proper content .
The "Elements" look like :
<<What_is_the_amoung_of_time_you_have_spent_at_university_in_the_current_semester>>
This "question" can in some rare cases be too big to fit it in and Prince cuts it off .
Is Word Wrap feature there in Prince 9 right now ? Is there a way to solve it ? I did try Word Wrap in css but didnt work out .

Please let me know . Thanks
sfinktah
I had this problem with URL's, the answer is purely javascript. You'll have to change this to suit your own requirements, but:

      $('span.hasUrl').each(function () {
         var $this = $(this);
         $this.text(
         $this.text().replace(/(https?:\/\/)([^\s]+)/g, function (match, p1, p2) {
            return p1 + p2.replace(/(\W)(\w)/g, String.fromCharCode(0x200b) + '$01$02')
         }));
      });


And by purely javascript, I meant - you will need to load the jQuery library. But not version 2.0, prince doesn't like that.

Edited by sfinktah

mikeday
You can use the prince-text-replace property to replace underscore with underscore + zero-width space, which is a little easier than using JavaScript for the same purpose. Prince already adds a zero-width space after the slash in URLs (controlled by the prince-linebreak-magic property).
sfinktah
A zero-width space would be '\20\0b' in CSS, I believe. (Same as what I used in the javascript).
mikeday
Surely just \200b? Otherwise \20\0b would be space followed by vertical tab.