New line breaks in HTML rendered using Richtext

Hi

I am using a web agent to generate a html string and use Call rtitem.AppendText(html) to write this html string to a rich text item. It works perfectly fine but sometimes i see some weird affect where new lines are inserted in the string causing the html output to break.

The html string i build is pretty large in length. Is there any known issue whereby domino puts new lines or break in long string on it’s own.

Regards

Siddharth

Subject: New line breaks in HTML rendered using Richtext

Hi

use getformattedtext method and try it out.

kavitha.

Subject: New line breaks in HTML rendered using Richtext

Could it be you are hitting the 64k paragraph size limit?

Is there any scope to force a suitable paragraph break in your HTML at appropriate points?

HTH - Rufus.

Subject: RE: New line breaks in HTML rendered using Richtext

Hi

The requirement is to construct a HTML table in the web query open. For this reason i cannot put a suitable paragraph break which would break the entire structure.

Regrading the earlier response which talks about using getFormattedtext i think this method is used to read text from a richtext field, i am just writing a string into a rich text field.

Thanks

Siddharth

Subject: RE: New line breaks in HTML rendered using Richtext

Paragraph breaks would not break the whole structure, as HTML simply ignores
whitespace in such context. Whether your HTML is:

First cellSecond cell

or

First cell Second cell

with paragraphs shown as separate lines above, makes no difference to the HTML
interpretation. See below for the firts and then the second, both rendered
simply by adding the passthrough HTML attribute:

The first:

First cellSecond cell

and the second:

First cell Second cell

Subject: the problem probably is that paragraph breaks are random

They do not fall necessarily on whitespace and/or in some cases linebreaks matter. Say:<table bgcolor='tomat

o’ border=‘1’>

will probably be bad, same as splitting a line of JavaScript in the middle.

Still I seem to remember that adding CRLF [Chr(13)+Chr(10)] in the middle of the HTML allowed to escape this problem. At least I remember adding text to HTML and checking that it does not reach some some particular size. If next chunk of text would go over the limit I added (well, I think it was CRLF?) In this way there were no “arbitrary” breaks.

Subject: RE: the problem probably is that paragraph breaks are random

Agreed, but he is building the string himself, so he can choose where the breaks go, and he is using rich text, since he shows his code as rtitem.AppendText. If he doesn’t know the content, he may have trouble, but if he is building the content, he should just find a suitable spot.

By the way, place where it breaks on its own is way less that 64KB or even 32KB. I think it will add a break every 1024 characters, but I could be wrong. In any case, many paragraph breaks are probably required.

Subject: RE: the problem probably is that paragraph breaks are random

Hi all

Thanks very much for all your crucial hints.

The string always used to break after every multiple of 16384 characters.

I managed to write a function which formats the html such that no word at such positions are splitted here is the function code.

Function FormatHTML (html As String) As String

On Error Goto errHandle

Dim i As Double

Dim spaces As Integer

Dim startPos As Double

Dim checkChar As String

Dim nextChar As String

Dim tmp As String

Dim tmp1 As String



i=1



If Len(html)<16385 Then

	tmp=html

Else

	tmp=html

	While ( Cdbl(i*16384.0) < Len(html))

		checkChar=Mid(tmp,Cdbl(i*16384.0),1)

		nextChar=Mid(tmp,Cdbl(i*16384.0 +1),1 )

		tmp1=Mid(tmp,1,Cdbl(i*16384.0))

		If checkChar <> " " And nextChar <> " " Then

			'Avoid breaking a string in middle by deliberately  inserting spaces

			spaces=Len(Strrightback(tmp1, " "))

			tmp=Mid(tmp,1,Cdbl(i*16384.0-spaces))+String$(spaces," ")+Mid(tmp,Cdbl(i*16384.0- (spaces-1)))

		End If

		i=i+1

	Wend

End If



FormatHTML=tmp

ExitFunction :

Exit Function

errHandle :

Msgbox "Error : " + Error$ + " Line : "+ Cstr(Erl) + " String length: " + Cstr(Len(html))

FormatHTML="Error"

Resume ExitFunction

End Function

Thanks

Siddharth