Wrong formatting of line breaks in Rich-Text element - InfoPath Dev
in

InfoPath Dev

Wrong formatting of line breaks in Rich-Text element

Last post 02-15-2010 08:49 AM by Jimmy. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-15-2010 06:00 AM

    • JonnyW
    • Not Ranked
    • Joined on 02-15-2010
    • Posts 1

    Wrong formatting of line breaks in Rich-Text element

    Hi.

    I am using Infopath 2003 (SP3) and have a formatting problem with line breaks in a Rich-Text element.

    Writing text to the element and inserting line breaks by the usage of return works fine so far. When I select some text inclusive the line break in order to apply some formatting, say, changing to Arial 7pt. Then all the selected text except of the line break gets the formatting. You can see the missing formatting instruction when the generated XML file is opened by a text editor. The generated extract looks like

    <div xmlns="http://www.w3.org/1999/xhtml" style="MARGIN-TOP: 0.5pt; PADDING-RIGHT: 0cm; MARGIN-BOTTOM: 1.25pt; FONT-SIZE: 12pt"><span style="FONT-SIZE: 7pt"><font face="Arial">This is the first line </font></span></div>
    <div xmlns="http://www.w3.org/1999/xhtml" style="MARGIN-TOP: 0cm; PADDING-RIGHT: 0cm; MARGIN-BOTTOM: 6pt; FONT-SIZE: 12pt"><span style="FONT-SIZE: 7pt"><strong><font face="Arial"></font></strong></span> </div>
    <div xmlns="http://www.w3.org/1999/xhtml" style="MARGIN-TOP: 0cm; PADDING-RIGHT: 0cm; MARGIN-BOTTOM: 0pt; FONT-SIZE: 12pt"><span style="FONT-SIZE: 7pt"><strong><font face="Arial">Just another line.</font></strong></span></div>

    As can be seen the line break represented as whitespace " " is within the second div tag, but not with the font-tag. This becomes a problem when the content is used in other applications. E.g. in Word it results in a wrong formatting of the empty line (Arial 12pt instead of Arial 7pt). Beside that the line break is given as UTF-8=C2A0 or ASCII-decimal=160 that is the non breaking space. This results in Word into an "invisible" circle character.

    If one use a text element the line break will be represented as CR LF, i.e. ASCII decimal 0D 0A.

     It would be great if anybody of you could give me a hint on how to deal with line breaks properly.

     Thank you very much.

  • 02-15-2010 08:49 AM In reply to

    Re: Wrong formatting of line breaks in Rich-Text element

     Hello Jonny,

    I can see how this behavior would be frustrating to you and how it would be nice if at least the &nbsp; were placed inside all the tags instead of at the end of the DIV.

    Perhaps my attempts to reproduce your situation are not exactly mimicking your behavior, but my InfoPath (2007) seems to be rendering the markup a bit differently:

    <div xmlns="http://www.w3.org/1999/xhtml"><font style="FONT-SIZE: 7pt">A line</font></div>
    <div xmlns="http://www.w3.org/1999/xhtml"><font style="FONT-SIZE: 7pt"></font> </div>
    <div xmlns="http://www.w3.org/1999/xhtml"><font style="FONT-SIZE: 7pt">another line</font></div>
    <div xmlns="http://www.w3.org/1999/xhtml">Unformatted line</div>

    It seems strange that 2007 would use <font> tags while 2003 uses <span>s.  That seems like a step backwards, but the key difference is that the outer <div>s are not styled, while they are in your example.  Perhaps an upgrade to InfoPath 2007 could ameliorate the issue?

    Another possible (though fiddly) workaround to this issue could be to use soft returns (Shift+Enter).  These are rendered as <br /> tags in the markup, and should not cause the issues you describe here.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.